Selaa lähdekoodia

rewrote connhandler methods so they call send and recv from their superclass

digital 7 vuotta sitten
vanhempi
commit
bbe9179034
1 muutettua tiedostoa jossa 5 lisäystä ja 9 poistoa
  1. 5 9
      network/__init__.py

+ 5 - 9
network/__init__.py

@@ -82,7 +82,7 @@ class ConnHandlerBase(object):
         """
         raise NotImplemented()
 
-    async def recv(self):
+    async def recv(self,block_size=block_size):
         """
         This method waits for the client to send something and returns bytes!
         """
@@ -144,12 +144,12 @@ class ConnHandler(object):
         """
         self.send("Welcome client, this is the server sending!")
 
-    async def recv(self):
+    async def recv(self,block_size=block_size):
         """
         This method waits for the client to send something, decodes it and
         returns a string.
         """
-        data_received = await self.socket.recv(self.block_size)
+        data_received = await self.recv(block_size=block_size)
         data_decoded = data_received.decode("utf-8")
         return data_decoded
 
@@ -163,12 +163,8 @@ class ConnHandler(object):
         else:
             lschat.info("Server:"+data)
         data_encoded = bytes(data, "utf-8")
-        try:
-            await self.socket.send(data_encoded)
-            return True
-        except Exception as e:
-            lserver.error(e, exc_info=True)
-            return False
+        send_status = await self.send(data_encoded)
+        return send_status
 
 
 class ConnHandlerEcho(ConnHandler):