@@ -233,10 +233,11 @@ type of installation, each server processes owns the connections to a subset
233
233
of the clients. To make broadcasting work in this environment, the servers
234
234
communicate with each other through the message queue.
235
235
236
- The message queue service needs to be installed and configured separately. By
237
- default, the server uses `Kombu <http://kombu.readthedocs.org/en/latest/ >`_
238
- to access the message queue, so any message queue supported by this package
239
- can be used. Kombu can be installed with pip::
236
+ The message queue service needs to be installed and configured separately. One
237
+ of the options offered by this package is to use
238
+ `Kombu <http://kombu.readthedocs.org/en/latest/ >`_ to access the message
239
+ queue, which means that any message queue supported by this package can be
240
+ used. Kombu can be installed with pip::
240
241
241
242
pip install kombu
242
243
@@ -252,29 +253,40 @@ To configure a Socket.IO server to connect to a message queue, the
252
253
following example instructs the server to connect to a Redis service running
253
254
on the same host and on the default port::
254
255
255
- redis = socketio.KombuManager('redis://')
256
- sio = socketio.Server(client_manager=redis )
256
+ mgr = socketio.KombuManager('redis://')
257
+ sio = socketio.Server(client_manager=mgr )
257
258
258
259
For a RabbitMQ queue also running on the local server with default
259
260
credentials, the configuration is as follows::
260
261
261
- amqp = socketio.KombuManager('amqp://')
262
- sio = socketio.Server(client_manager=amqp )
262
+ mgr = socketio.KombuManager('amqp://')
263
+ sio = socketio.Server(client_manager=mgr )
263
264
264
- The arguments passed to the ``KombuManager `` constructor are passed directly
265
- to Kombu's `Connection object
265
+ The URL passed to the ``KombuManager `` constructor is passed directly to
266
+ Kombu's `Connection object
266
267
<http://kombu.readthedocs.org/en/latest/userguide/connections.html> `_, so
267
268
the Kombu documentation should be consulted for information on how to
268
269
connect to the message queue appropriately.
269
270
271
+ If the use of Kombu is not desired, native Redis support is also offered
272
+ through the ``RedisManager `` class. This class takes the same arguments as
273
+ ``KombuManager ``, but connects directly to a Redis store using the queue's
274
+ pub/sub functionality::
275
+
276
+
277
+ mgr = socketio.RedisManager('redis://')
278
+ sio = socketio.Server(client_manager=mgr)
279
+
270
280
If multiple Sokcet.IO servers are connected to a message queue, they
271
281
automatically communicate with each other and manage a combined client list,
272
282
without any need for additional configuration. To have a process other than
273
- the server connect to the queue to emit a message, the same ``KombuManager ``
274
- class can be used as standalone object. For example::
283
+ a server connect to the queue to emit a message, the same ``KombuManager ``
284
+ and ``RedisManager `` classes can be used as standalone object. In this case,
285
+ the ``write_only `` argument should be set to ``True `` to disable the creation
286
+ of a listening thread. For example::
275
287
276
- # connect to the redis queue
277
- redis = socketio.KombuManager('redis://localhost:6379/' )
288
+ # connect to the redis queue through Kombu
289
+ redis = socketio.KombuManager('redis://', write_only=True )
278
290
279
291
# emit an event
280
292
redis.emit('my event', data={'foo': 'bar'}, room='my room')
0 commit comments