'Handle requests on the server side.'

def handle(self):

    self.request.settimeout(None)
    while self.server.stim_server._running:
        data = self.request.recv(1024)
        data = data.decode()
        if (data == 'add    client'):
            client_id = self.server.stim_server._add_client(self.client_address[0], self)
            if (not hasattr(self, '_tx_queue')):
                self._tx_queue = queue.Queue()
            self.request.sendall('Client    added'.encode('utf-8'))
            for client in self.server.stim_server._clients:
                if (client['id'] == client_id):
                    client['running'] = True
        elif (data == 'get    trigger'):
            if (((self._tx_queue.qsize() > 0) and self.server.stim_server), '_clients'):
                trigger = self._tx_queue.get()
                self.request.sendall(str(trigger).encode('utf-8'))
            else:
                self.request.sendall('Empty'.encode('utf-8'))
