Commits

Ginés Martínez Sánchez committed 64e0113 Draft

developing sockjs server

Comments (0)

Files changed (3)

ginsfsm/c_sock.py

 def ac_write_output_data(self, event):
     """ Write in the output data buffer.
         Equivalent to waitress' write_soon().
+        The data are not really sent until _send_some() is called.
     """
     self._write_soon(event.data)
 

ginsfsm/protocols/sockjs/server/c_sockjs_server.py

 from ginsfsm.compat import string_types
 from ginsfsm.globals import get_global_app
 from ginsfsm.protocols.http.server.c_http_server import GHttpServer
-from ginsfsm.protocols.wsgi.common.wsgi_response import SockjsResponse
 from ginsfsm.protocols.http.server.c_http_server import GHTTPSERVER_GCONFIG
+from ginsfsm.protocols.wsgi.common.wsgi_response import WsgiResponse
 
 
 def ac_channel_opened(self, event):
     channel = event.source[-1]
     request = event.request
     application = self.select_app(request)
-    response = SockjsResponse(request, self, application)
+    response = WsgiResponse(request, self, application)
     self.send_event(channel, 'EV_HTTP_RESPONSE', response=response)
 
 
-GWSGISERVER_FSM = {
+GSOCKJSSERVER_FSM = {
     'event_list': (
         'EV_HTTP_CHANNEL_OPENED: bottom input',
         'EV_HTTP_CHANNEL_CLOSED: bottom input',
     }
 }
 
-GWSGISERVER_GCONFIG = GHTTPSERVER_GCONFIG.copy()
-GWSGISERVER_GCONFIG.update({
+GSOCKJSSERVER_GCONFIG = GHTTPSERVER_GCONFIG.copy()
+GSOCKJSSERVER_GCONFIG.update({
     'application': [None, None, 0, None, "wsgi application"],
 })
 
 
 class GSockjsServer(GObj):
-    """  WSGI Server gobj.
+    """  SOCKJS Server gobj.
 
     The incoming connections will create a new :class:`ginsfsm.c_sock.GSock`
     :term:`gobj`,
            destroy the `gobj` because the connection ceases to exist.
 
     .. ginsfsm::
-       :fsm: GWSGISERVER_FSM
-       :gconfig: GWSGISERVER_GCONFIG
+       :fsm: GSOCKJSSERVER_FSM
+       :gconfig: GSOCKJSSERVER_GCONFIG
 
     *Input-Events:*
 
     """
 
     def __init__(self):
-        GObj.__init__(self, GWSGISERVER_FSM, GWSGISERVER_GCONFIG)
+        GObj.__init__(self, GSOCKJSSERVER_FSM, GSOCKJSSERVER_GCONFIG)
         self._n_connected_clisrv = 0
 
     def start_up(self):

ginsfsm/protocols/wsgi/common/wsgi_response.py

 
         environ = {}
         # Own variables to do asynchronous response
-        environ['channel'] = channel
-        environ['gaplic'] = channel.gaplic
-        #environ['ext_event'] = self.ext_event
+        environ['ginsfsm.channel'] = channel
+        environ['ginsfsm.gaplic'] = channel.gaplic
+        environ['ginsfsm.request'] = request
 
         environ['REQUEST_METHOD'] = request.command.upper()
         environ['SERVER_PORT'] = str(wsgi_server.effective_port)