Re: [Twisted-web] Callback help client / server
"Chris" == Chris <datarecall@hotmail.com> writes: Chris> I am trying to figure out a way so I can access the datareceived Chris> outside of the Echo Class so I can run operations on the data Chris> received.
Your protocol knows when it has received something that needs to be acted on. So the simplest possibility is to have the protocol take the action. If that's too simple, you can have the protocol call a method on the factory. So at some point (perhaps in dataReceived) the protocol calls self.factory.doSomething(). Look at the source of twisted.internet.protocols.Factory and you'll see that buildProtocol puts a factory attribute on the newly created protocol instance. The factory can then implement the higher level processing. If that's still not suitable, you can build other options by, e.g., passing something to the factory initializer that it puts onto protocol instances for the protocol to call directly. Take a look at HTTPClientFactory and its HTTPPageGetter protocol in twisted/web/client.py for an instructive example. Terry
participants (1)
-
Terry Jones