Anonymous committed d637608

Add ability to disconnect all clients

  • Participants
  • Parent commits 8296cba
  • Tags v0.7.1

Comments (0)

Files changed (5)

 SockJSProxy is a simple proxy server that proxies message from SockJS_ to a
 ZeroMQ_ socket and vise-versa.
+Using it you can create real-time web-based application in any backend
+language you'd like.
-The incomming messages socket is a ``PUSH`` one (by default on port ``9241``), where
+The incomming messages (i.e. sent by the client, usually a browser)
+socket is a ``PUSH`` one (by default on port ``9241``), where
 the proxy will push messages to. All messages are 3-part messages in the form of:
 | ``data``         |
-``message_type`` can be one of these. The other arguments are described under each
+``message_type`` can be one of those, listed below. ``session_id`` can be
+used to identify the connection. A reconnect of the
+client will result in a new session id.
     Sent when a client connects to the server. The ``session_id`` is set,
-The outgoing socket is a ``PULL`` one (by default on port ``9242``), where the
+The outgoing (for messages you wish to send to the client)
+socket is a ``PULL`` one (by default on port ``9242``), where the
 proxy will read messages and forward them to the SockJS client (usually a browser).
 The format is like the one for incomming messages:
     Send this to forward a message to a client with ``session_id``.
-    ``data`` contains the message (as bytes) for the client.
+    ``data`` contains the message for the client.
     Disconnect the client with the given ``session_id``.
     ``data`` is discarded but *must* be present in the message as
     a part (usually empty).
+    Disconnect all connected clients. ``session_id`` and ``data``
+    are discarded, but *must* be present in the message (leaving
+    them empty is a good idea).
       --verbose, -v         Make the server output more information - useful for
+Stopping the server
+When the server is running in the foreground - pressing ``Ctrl+C`` would stop it.
+If you use something like ``nohup`` do deamonize it - send it ``SIGTERM``
+(see ``man kill`` for more info) and it will gracefully stop.
+  - Added ``disconnectall`` capability to force all clients
+    to disconnect.
   - Switch from ``PUB/SUB`` socket pair to ``PUSH/PULL``.
   - Add support to force the client to disconnect.
 #!/usr/bin/env python
-"""SockJSProxy - Proxy SockJS message to/from ZeroMQ PUSH/PULL sockets.
+"""SockJSProxy - Proxy SockJS messages to/from ZeroMQ PUSH/PULL sockets.
 See the `samples/` file for an example client.

File sockjsproxy/

-VERSION = '0.7.0'
+VERSION = '0.7.1'

File sockjsproxy/samples/

                                            'The time now is: ' + str(])
-                out_socket.send_multipart(['disconnect',
-                                           session_id,
-                                           ''])
+                out_socket.send_multipart(['disconnect', session_id, ''])
+                # out_socket.send_multipart(['disconnectall', '', ''])
     except KeyboardInterrupt:

File sockjsproxy/

             self.frontend.send(session_id, message)
         elif command == 'disconnect':
+        elif command == 'disconnectall':
+            self.frontend.close_all()
             log.warn("Invalid command %s", command)
+    def close_all(self):
+        for c in self.sessions.values():
+            c.close()
 class SockJSProxy(object):
     def collect_args(self):