Example #1
0
    def send(self, message, data=None, text=None, simple=True):
        if simple:
            request = simple_request(message,
                                     client_id=self.client_id,
                                     text=text,
                                     data=data)
        else:
            request = message
        try:
            self.socket.send(request)
        except Again:
            self.socket.send(request)

        return simple_response(self.recv())
Example #2
0
 async def send(self, message, data=None, text=None, simple=True):
     if simple:
         request = simple_request(message,
                                  client_id=self.client_id,
                                  data=data,
                                  text=text)
     else:
         request = message
     try:
         await self.socket.send(request)
     except Again:
         await self.socket.send(request)
     try:
         response = simple_response(await self.socket.recv())
     except Again:
         response = simple_response(await self.socket.recv())
     return response