[Twisted-Python] PB - Dual Use Objects?
serj_trejo at hotmail.com
Sun Jul 18 05:02:54 EDT 2004
Radix -- this was an excellent suggestion - it works quite well. Thanks for
your trips. Its been interesting delving into the aspects of Avatars, the
Mind, Realms and Portals. Good stuff.
>From: Christopher Armstrong <radix at twistedmatrix.com>
>Reply-To: Twisted discussion stuff <twisted-python at twistedmatrix.com>
>To: Twisted discussion stuff <twisted-python at twistedmatrix.com>
>Subject: Re: [Twisted-Python] PB - Dual Use Objects?
>Date: Fri, 16 Jul 2004 12:45:32 -0400
>Sergio Trejo wrote:
>>I'm curious, for those who use PB for their projects, do they make their
>>objects at each end of the wire dual use (meaning, both objects run a PB
>>Server and PB Client Factory such that each object can remotely call the
>>other), or do most people stick to a typical client-server model wherby
>>the PB Server Factory object just waits for requests from the Client and
>>does not attempt to initiate any messages to the client?
>>I ask because as a newbie to Twisted, I also started reading the
>>twisted.flow HowTo and it looks like there are some really interesting
>>things that could be done with PB. I have an app in mind whereby a PB
>>Client (A) triggers a PB Server, and then the PB Server expects incoming
>>data from another PB Client (B) but the data that comes in from B is
>>useful to pass back to A (all in a deferred manner however). Therefore the
>>PB Server acts as an intermediary. But this could get really hairy if I
>>turned the PB Server into a server handling multiple requests from PB
>>Clients of type A and PB Clients of type B (could look like a spaghetti
>>bowl f the Server is required to route data from the Bs to the As) so
>>maybe better to stick with a typical client-server model.
>No, this is very simple. First of all, you need the Bs to pass a "mind"
>object to pb.login(). It'll probably be a Referenceable subclass instance.
>You'll get this mind object passed to your Realm's requestAvatar method, so
>you can save it wherever relevant there. Let's pretend this object has a
>messageFromAnA remote method.
>Then the As connect, and do middleman.callRemote('doSomethingToAB'):
> return self.mind.callRemote('messageFromAnA')
>callRemote will return a Deferred that fires with the result from B's
>messageFromAnA method, and PB will pass this result off as the result to A,
>so A is getting the result that B returned.
> Twisted | Christopher Armstrong: International Man of Twistery
> Radix | Release Manager, Twisted Project
><< signature.asc >>
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
More information about the Twisted-Python