Le 2 mars 2013 à 19:12, Tom Prince <tom.prince@ualberta.net> a écrit :
Benjamin BERTRAND <beenje@gmail.com> writes:
Le 2 mars 2013 à 15:33, Laurens Van Houtven <_@lvh.cc> a écrit :
I'm guessing that this is another question that will be solved as soon as I see the code (perhaps you should put all your code up somewhere); but all I do know is that all Deferreds buy you is an abstraction for organizing callbacks; it's not a dispatch mechanism (and if you're using it as one now, you do have dispatch logic, it just lives somewhere else).
The dispatch is done in the pcapDataReceived method (in the ServerFactory) thanks to the dictionary of deferred (using the line id as key). And each line is associated to a server on a specific port.
Instead sticking a deferred in that dictionary, you could just stick the `Oldimon` protocol instance, or the bound method (i.e. `self.sendMessage`) in that dictionary. In which case `messageToSend` becomes obsolete, since you don't need to rearm it each time.
Good point! I guess I should try to think more "Python" before trying to think "Twisted" :-) Thanks Benjamin
Tom