[Twisted-Python] Keeping a list of connected PB clients

Yi Qiang yqiang at gmail.com
Sun Nov 19 17:00:13 MST 2006


Hi,
I am trying to figure out how to keep an continuously updated list of
connected clients to a PB server.
I have had success in figuring out how to add clients to my list when they
connect, but I am not sure what methods get called when a client
disconnects.

This is what I have so far:

from twisted.spread import pb

class DSagePBServerFactory(pb.PBServerFactory):
    def __init__(self, root):
        pb.PBServerFactory.__init__(self, root)
        self.clients = []

    def clientConnectionMade(self, broker):
        """Keeps a 3-tuple of connected clients.
        tuple[0] - the broker transport
        tuple[1] - the clients ip
        tuple[2] - the clients port

        """
        self.clients.append((broker.transport,
                             broker.transport.getPeer().host,
                             broker.transport.getPeer().port))
        print self.clients

There does not seem to be a corresponding clientConnectionLost method for
the Factory class.  Any suggestions would be appreciated.

Yi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20061119/6b50c11f/attachment.html>


More information about the Twisted-Python mailing list