modifié: superTornado.py

modifié:         test.html
This commit is contained in:
sidya82
2014-02-27 21:38:17 +01:00
parent 493e758031
commit 54f193051b
2 changed files with 41 additions and 37 deletions

View File

@ -47,19 +47,22 @@ class VideoHandler(tornado.web.RequestHandler):
def get(self):
self.render("test.html")
class WSHandler(tornado.websocket.WebSocketHandler):
def open(self):
self.callback = PeriodicCallback(self.send_hello, 120)
self.callback.start()
def send_hello(self):
self.write_message('hello')
class WebSocketHandler(tornado.websocket.WebSocketHandler):
def open(self, *args):
self.id = self.get_argument("Id")
self.stream.set_nodelay(True)
clients[self.id] = {"id": self.id, "object": self}
def on_message(self, message):
pass
"""
when we receive some message we want some message handler..
for this example i will just print message to console
"""
print "Client %s received a message : %s" % (self.id, message)
def on_close(self):
self.callback.stop()
if self.id in clients:
del clients[self.id]
application = tornado.web.Application([