In my ongoing curiosity about websockets, I\'m noticing a trend:
The \"hello world\" of the websocket universe, at least at the moment, seems to be \"echo\" function
This is an example of an updated EchoHandler that will instead of just being reactive, be proactive.
class ChattyHandler(WebSocketHandler):
def connectionMade(self):
self.transport.write('oh hai\n')
self.saysomething()
def saysomething(self):
self.transport.write('still there?\n')
reactor.callLater(5, self.saysomething)
Unfortunately, websockets from https://github.com/rlotun/txWebSocket/ doesn't seem to have the connectionMade() method, and instead the only thing you can hook into is the __init__. usually you would just override connectionMade() if it were a 'normal' twisted protocol. --Fixed in upstream
Using hendrix, I showed how to set up a web app in a talk at Django-NYC that uses websockets to push messages from a telnet server to a web page.