Commit 6807fc3f authored by Taddeüs Kroes's avatar Taddeüs Kroes

Changed onexception() to onerror(), fixed some typo's

parent 6641c0c4
......@@ -111,7 +111,7 @@ class Connection(object):
self.onclose(None, '')
break
except Exception as e:
self.onexception(e)
self.onerror(e)
def send_close(self, code, reason):
"""
......@@ -191,7 +191,7 @@ class Connection(object):
"""
return NotImplemented
def onexception(self, e):
def onerror(self, e):
"""
Handle a raised exception.
"""
......
......@@ -26,7 +26,7 @@ class Server(object):
>>> def onmessage(self, client, message):
>>> # handle message from client
>>> GameServer(port=8000).run()
>>> GameServer(8000).run()
"""
def __init__(self, port, hostname='', loglevel=logging.INFO, protocols=[]):
......@@ -96,7 +96,7 @@ class Server(object):
logging.debug(msg)
def onexception(self, client, e):
def onerror(self, client, e):
logging.error(format_exc(e))
......@@ -120,8 +120,8 @@ class Client(Connection):
def onclose(self, code, reason):
self.server.remove_client(self, code, reason)
def onexception(self, e):
self.server.onexception(self, e)
def onerror(self, e):
self.server.onerror(self, e)
def __str__(self):
return '<Client at %s:%d>' % self.sock.getpeername()
......@@ -129,5 +129,5 @@ class Client(Connection):
if __name__ == '__main__':
import sys
port = int(sys.argv[1]) if len(sys.argv) > 1 else 80
port = int(sys.argv[1]) if len(sys.argv) > 1 else 8000
Server(port, loglevel=logging.DEBUG).run()
......@@ -21,7 +21,7 @@ class websocket(object):
Server example:
>>> sock = websocket()
>>> sock.bind(('', 80))
>>> sock.bind(('', 8000))
>>> sock.listen()
>>> client = sock.accept()
......@@ -30,7 +30,7 @@ class websocket(object):
Client example:
>>> sock = websocket()
>>> sock.connect(('kompiler.org', 80))
>>> sock.connect(('', 8000))
"""
def __init__(self, protocols=[], extensions=[], sfamily=socket.AF_INET,
sproto=0):
......@@ -57,7 +57,7 @@ class websocket(object):
"""
Equivalent to socket.accept(), but transforms the socket into a
websocket instance and sends a server handshake (after receiving a
client handshake). Note that the handshake may raise an HandshakeError
client handshake). Note that the handshake may raise a HandshakeError
exception.
"""
sock, address = self.sock.accept()
......
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