TCP server

I created a tcp server, I added it as custom in my yaml file, the tcp server is running and listening on a port.
What I want to do is to turn my switches on or off according to the data coming to the tcp port.
Sample;
#Relay1ON” // relay1 turn_on
#Relay1OFF” // relay1 turn_off
I couldn’t do it because I’m using gpio. Can you write me an example code that might help?

I’m sorry for my bad english.

My TCP_Server

#include "esphome.h"
#include "ESP8266WiFi.h"

WiFiServer wifiServer(5000);
class MyCustomComponent  : public Component  {
 public:
  void setup() override {
    wifiServer.begin();
  }

 void loop() override {
	 WiFiClient client = wifiServer.available();
 
  if (client) {
 
    while (client.connected()) {
 
      while (client.available()>0) {
        char c = client.read();
        Serial.write(c);

      }
 
      delay(10);
    }
 
    client.stop();
    Serial.println("Client disconnected");
 
  }
 }
};

My YAML:

esphome:
  includes:
    - tcpserver.h
  name: viparac

esp8266:
  board: esp01_1m

# Enable logging
logger:

  
custom_component:
- lambda: |-
    auto my_custom = new MyCustomComponent();
    return {my_custom};

# Example configuration entry
sn74hc595:
  - id: 'sn74hc595_hub'
    data_pin: GPIO14
    clock_pin: GPIO13
    latch_pin: GPIO12
    oe_pin: GPIO05
    sr_count: 2

# Individual outputs
switch:
  - platform: gpio
    id: test1
    name: "Relay 1"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 0
      number: 0
      inverted: false
  - platform: gpio
    name: "Relay 2"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 1
      number: 1
      inverted: false
  - platform: gpio
    name: "Relay 3"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 2
      number: 2
      inverted: false
  - platform: gpio
    name: "Relay 4"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 3
      number: 3
      inverted: false
  - platform: gpio
    name: "Relay 5"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 4
      number: 4
      inverted: false