[Twisted-Python] PB release connection
Uwe C. Schroeder
uwe at oss4u.com
Sun Sep 26 04:59:46 EDT 2004
-----BEGIN PGP SIGNED MESSAGE-----
That works for me too. Maybe I need to reword that.
How do you release the connection from a PBServerFactory instance (where you
usually don't have a reference to) ?
On Saturday 25 September 2004 04:28 pm, Jasper Phillips wrote:
> On Sat, 25 Sep 2004, Uwe C. Schroeder wrote:
> > Now I'd like to be able to get rid of a specific client (which holds a
> > remote-reference to MyPerspective). With the old pb api there was a way
> > to do call perspective.broker.transport.loseConnection(), which I was
> > using on the client side to end the connection.
> > I can't see anything like this with the new API that would allow me to
> > initiate the "kick off" from the server side.
> > Can this be done? What would be the propper way to release a connection
> > from the server side?
> > Thanks for any enlightenment.
> > Uwe
> I don't know what the "proper" way to release a connection is, but
> "perspective".broker.transport.loseConnection() works for me, where
> "perspective" is whatever name you assign to the arg of the "connected"
> callback attached to PBClientFactory.login()
> Here's a minimal snippet of what I use, cutting out code specific to my
> class NetworkClient( pb.Referenceable ):
> def __init__( self ):
> self.remote = None
> def connect( self, ipAddress, port, user, password ):
> factory = pb.PBClientFactory()
> reactor.connectTCP( ipAddress, port, factory )
> defer = factory.login( credentials.UsernamePassword( user, password),
> client=self )
> defer.addCallbacks( self.connected, self.connectFailled )
> return defer
> def disconnect( self ):
> def connected( self, perspective ):
> print "Connect Succeeded to:", self.remote
> self.remote = perspective
> self.remote.notifyOnDisconnect( self.disconnected )
> def disconnected( self, perspective ):
> print "Connection Severed"
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the Twisted-Python