Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #32.

  • Loading branch information...
commit 35df83bf28dc670d3423a9390fce1aa37888e378 1 parent db43803
@mrjoes authored
Showing with 18 additions and 8 deletions.
  1. +6 −6 README.rst
  2. +12 −2 tornadio2/persistent.py
View
12 README.rst
@@ -44,7 +44,7 @@ If you're familiar with Tornado, do following to add support for Socket.IO to yo
class MyConnection(tornadio2.SocketConnection):
def on_message(self, message):
- pass
+ pass
2. Create TornadIO2 server for your connection::
@@ -52,9 +52,9 @@ If you're familiar with Tornado, do following to add support for Socket.IO to yo
3. Add your handler routes to the Tornado application::
- application = tornado.web.Application(
- MyRouter.urls,
- socket_io_port = 8000)
+ application = tornado.web.Application(
+ MyRouter.urls,
+ socket_io_port = 8000)
4. Start your application
5. You have your `socket.io` server running at port 8000. Simple, right?
@@ -67,8 +67,8 @@ simplifies start of your TornadIO server.
To start it, do following (assuming you created application object before)::
- if __name__ == "__main__":
- socketio_server = SocketServer(application)
+ if __name__ == "__main__":
+ socketio_server = SocketServer(application)
SocketServer will automatically start Flash policy server, if required.
View
14 tornadio2/persistent.py
@@ -22,6 +22,7 @@
"""
import logging
import time
+import traceback
import tornado
from tornado.web import HTTPError
@@ -120,6 +121,10 @@ def on_message(self, message):
# Tracking
self.server.stats.on_packet_recv(1)
+ # Fix for late messages (after connection was closed)
+ if not self.session:
+ return
+
# Mark that connection is active and flush any pending messages
if not self._is_active:
# Associate session handler and flush queued messages
@@ -129,11 +134,16 @@ def on_message(self, message):
self._is_active = True
+ self.session.delay_heartbeat()
+
try:
self.session.raw_message(message)
- except Exception:
+ except Exception, ex:
+ logging.error('Failed to handle message: ' + traceback.format_exc(ex))
+
# Close session on exception
- self.session.close()
+ if self.session is not None:
+ self.session.close()
def on_close(self):
self._detach()
Please sign in to comment.
Something went wrong with that request. Please try again.