[Twisted-Python] How to send message to all connected clients
exarkun at intarweb.us
Sun Jul 20 21:40:41 EDT 2003
On Mon, Jul 21, 2003 at 11:30:03AM +1000, Minh Luu wrote:
> Could I have some advice on how to send a message to all connected clients.
> Where do I keep the list of the client connections - in the sub-class of Protocol
> or in the sub-class of Factory?
Definitely in your Factory subclass. You can add Protocol instances to
the list in your buildProtocol() method and remove them either the Factory's
clientConnectionLost() method or the Protocol's connectionLost() method.
> Do I call the write method for each client connection or there is a better way in twisted
> to send a message to all the clients or a group of clients.
If you're using TCP, doing a write() on each connection is pretty much a
requirement. If you're using UDP, you might be able to manage something
better with multicast (but since you mentioned factories, I'm guessing
you're not using UDP).
Hope this helps,
Somewhere, something incredible is waiting to be known.
-- Carl Sagan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20030720/29dc6e62/attachment.pgp
More information about the Twisted-Python