[Twisted-Python] Chat server

Bob Ippolito bob at redivi.com
Fri Oct 17 16:41:04 MDT 2003


On Friday, Oct 17, 2003, at 16:37 America/New_York, Ted Patrick wrote:

> Using twisted as a socket server, how would you pass a message to all
> attached clients. Like the echo example but broadcast the message to 
> all
> attached clients.

You need to have a dictionary connected clients somewhere, the best 
place would probably be the factory instance.  When a client connects, 
add them to the dictionary, when they disconnect remove them from the 
dictionary.  Then just add a method to your class that sends a message 
to every client that the factory knows about.

-bob





More information about the Twisted-Python mailing list