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

Code cleanup

parent 7cf4ddca
......@@ -47,12 +47,6 @@ class Server(object):
"""
pass
def onclose(self, client):
"""
Called when a client disconnects.
"""
pass
def onmessage(self, client, message):
"""
Called when a message is received from some client. `message' is a
......@@ -60,15 +54,27 @@ class Server(object):
"""
raise NotImplemented
def onclose(self, client):
"""
Called when a client disconnects.
"""
pass
class Client(WebSocket):
def __init__(self, server, sock, address):
super(Client, self).__init__(sock, address)
self.server = server
def handle_message(self, message):
def onopen(self):
self.server.onopen(self)
def onmessage(self, message):
self.server.onmessage(self, message)
def onclose(self):
self.server.onclose(self, message)
def __str__(self):
return '<Client at %s:%d>' % self.address
......
......@@ -93,12 +93,6 @@ class WebSocket(FrameReceiver):
"""
pass
def onclose(self):
"""
Called when the other end of the socket disconnects.
"""
pass
def onmessage(self, message):
"""
Called when a message is received. `message' is a Message object, which
......@@ -106,5 +100,11 @@ class WebSocket(FrameReceiver):
"""
raise NotImplemented
def onclose(self):
"""
Called when the other end of the socket disconnects.
"""
pass
def close(self):
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