Commits

Ginés Martínez Sánchez  committed 046dc68 Draft

developing sockjs

  • Participants
  • Parent commits b8d3373

Comments (0)

Files changed (4)

File ginsfsm/protocols/sockjs/server/c_sockjs_server.py

         "Class to receive sockjs events."
         "GSockjsServer will create a instance of this class."
     ],
+    'permission': [None, None, 0, None, "Pyramid permission"],
+
+    # like tornado settings
+    'session_check_interval': [int, 1, 0, None,
+        "Sessions check interval in seconds"],
+    'disconnect_delay': [int, 5, 0, None,
+        "Session expiration in seconds"],
+    'heartbeat_delay': [int, 25, 0, None,
+        "Heartbeat time in seconds. Do not change this value unless "
+        "you absolutely sure that new value will work."
+    ],
     'disabled_transports': [tuple, (), 0, None, "Transports disabled"],
-
     'sockjs_url': [str,
         'http://cdn.sockjs.org/sockjs-0.3.min.js', 0, None, "SockJS location"
     ],
-    'permission': [None, None, 0, None, "Pyramid permission"],
-    'cookie_needed': [bool, True, 0, None, ""],
+    'response_limit': [int, 128 * 1024, 0, None, "Max response body size"],
+    'jsessionid': [bool, True, 0, None,
+        "Enable or disable JSESSIONID cookie handling"
+    ],
+    'verify_ip': [bool, True, 0, None,
+        "Enable IP checks for polling transports. If enabled, "
+        "all subsequent polling calls should be from the same IP address."
+    ],
 }
 
 

File ginsfsm/protocols/sockjs/server/transports/pollingbase.py

 class PollingTransportBase(basehandler.PreflightHandler, base.BaseTransportMixin):
     """Polling transport handler base class"""
     def __init__(self, context, request):
-        super(PollingTransportBase, self).__init__(self, context, request)
+        super(PollingTransportBase, self).__init__(context, request)
         self.session = None
         self.active = True
 

File ginsfsm/protocols/sockjs/server/transports/streamingbase.py

 
 class StreamingTransportBase(pollingbase.PollingTransportBase):
     def __init__(self, context, request):
-        super(StreamingTransportBase, self).__init__(self, context, request)
+        super(StreamingTransportBase, self).__init__(context, request)
 
-        self.amount_limit = self.server.settings['response_limit']
+        self.amount_limit = self.context.sockjs_server.response_limit
 
         # HTTP 1.0 client might send keep-alive
         if hasattr(self.request, 'connection') and not self.request.supports_http_1_1():

File ginsfsm/protocols/sockjs/server/transports/xhrstreaming.py

 class XhrStreamingTransport(streamingbase.StreamingTransportBase):
     name = 'xhr_streaming'
 
-    def post(self, session_id):
+    #def post(self, session_id):
+    def post(self):
         # Handle cookie
+        session_id = '?'
+        response = self.response
+        response.content_type = 'application/javascript; charset=UTF-8'
         self.preflight()
         self.handle_session_cookie()
         self.disable_cache()
-        self.set_header('Content-Type', 'application/javascript; charset=UTF-8')
 
         # Send prelude and flush any pending messages
-        self.write('h' * 2048 + '\n')
-        self.flush()
+        response.body = 'h' * 2048 + '\n'
+        #self.flush()
 
         if not self._attach_session(session_id, False):
             self.finish()