[Twisted-Python] From factory to protocol
grimmtooth at softhome.net
Thu Feb 13 17:28:04 EST 2003
> Is it somehow possible to get to the protocol from the factory?
In addition to what Kevin mentioned, if you don't want to override the
native methods in your factory, keep in mind that the protocol DOES have
a reference back to the factory that created it.
What I did in this instance was add two methods to the factory: one that
the protocol called when it was created, and one when it was done. The
first added the protocol to a list (actually, for me, a dict)of
protocols that the factory could use, and the second one was to remove
the protocol from the list.
I elected to do it this way because each of my protocols is assigned a
unique name and may have a user attached on the other end (telnet). I
then control these protocols in various ways through the factory.
Well... On paper anyway. I haven't gotten much past the code to kill off
all the protocols gracefully then exit.
More information about the Twisted-Python