modifié: superTornado.py
modifié: test.html
This commit is contained in:
@ -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([
|
||||
|
Reference in New Issue
Block a user