Commit 390212ed authored by Taddeüs Kroes's avatar Taddeüs Kroes

Code cleanup

parent 7cf4ddca
...@@ -47,12 +47,6 @@ class Server(object): ...@@ -47,12 +47,6 @@ class Server(object):
""" """
pass pass
def onclose(self, client):
"""
Called when a client disconnects.
"""
pass
def onmessage(self, client, message): def onmessage(self, client, message):
""" """
Called when a message is received from some client. `message' is a Called when a message is received from some client. `message' is a
...@@ -60,15 +54,27 @@ class Server(object): ...@@ -60,15 +54,27 @@ class Server(object):
""" """
raise NotImplemented raise NotImplemented
def onclose(self, client):
"""
Called when a client disconnects.
"""
pass
class Client(WebSocket): class Client(WebSocket):
def __init__(self, server, sock, address): def __init__(self, server, sock, address):
super(Client, self).__init__(sock, address) super(Client, self).__init__(sock, address)
self.server = server self.server = server
def handle_message(self, message): def onopen(self):
self.server.onopen(self)
def onmessage(self, message):
self.server.onmessage(self, message) self.server.onmessage(self, message)
def onclose(self):
self.server.onclose(self, message)
def __str__(self): def __str__(self):
return '<Client at %s:%d>' % self.address return '<Client at %s:%d>' % self.address
......
...@@ -93,12 +93,6 @@ class WebSocket(FrameReceiver): ...@@ -93,12 +93,6 @@ class WebSocket(FrameReceiver):
""" """
pass pass
def onclose(self):
"""
Called when the other end of the socket disconnects.
"""
pass
def onmessage(self, message): def onmessage(self, message):
""" """
Called when a message is received. `message' is a Message object, which Called when a message is received. `message' is a Message object, which
...@@ -106,5 +100,11 @@ class WebSocket(FrameReceiver): ...@@ -106,5 +100,11 @@ class WebSocket(FrameReceiver):
""" """
raise NotImplemented raise NotImplemented
def onclose(self):
"""
Called when the other end of the socket disconnects.
"""
pass
def close(self): def close(self):
raise SocketClosed() raise SocketClosed()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment