Commit 64be404f authored by Taddeüs Kroes's avatar Taddeüs Kroes

Added example code from README as a test script

parent d4362ea8
#!/usr/bin/env python
import socket
import wspy
class EchoConnection(wspy.Connection):
def onopen(self):
print 'Connection opened at %s:%d' % self.sock.getpeername()
def onmessage(self, message):
print 'Received message "%s"' % message.payload
self.send(wspy.TextMessage(message.payload))
def onclose(self, code, reason):
print 'Connection closed'
server = wspy.websocket()
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('', 8000))
server.listen(5)
try:
while True:
client, addr = server.accept()
EchoConnection(client).receive_forever()
except KeyboardInterrupt:
pass
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