> Here's some untested code: > > class SmartEcho(Protocol): > implements(IProducer) > > def pauseProducing(self): > self.transport.pauseProducing() > > def resumeProducing(self): > self.transport.resumeProducing() > > def stopProducing(self): > self.transport.stopProducing() > > def connectionMade(self): > self.transport.registerProducer(self, True) > > def dataReceived(self, bytes): > self.transport.write(bytes) > > A careful examination of this code should also reveal the > fact that it can be shortened to a more obscure form: > > class SmartEcho(Protocol): > def connectionMade(self): > self.transport.registerProducer(self.transport, True) > > def dataReceived(self, bytes): > self.transport.write(bytes) > > Hope this helps, > Jean-Paul > Thanks a lot. It definitely helped me. I knew how to set up a producer, I just didn't know that my class was automatically going to be registered as a consumer for transport. And I didn't know that i could call transport.registerProducer(self.transport)! Unfortunately twisted is as powerful as poorly documented sometimes.
Pietro _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python