Twisted factory protocol instance based callback
Hey, I got a ReconnectingClientFactory
and I开发者_运维问答 wonder if I can somehow define protocol-instance-based connectionMade
/connectionLost
callbacks so that i can use the factory to connect to different hosts ans distinguish between each connection.
Thanks in advance.
No. Write a class that does the interaction with one user. In connectionMade
you check if a instance of this class already exists, if not you make a new one and store it on the factory, ie in a { addr : handler }
dict. If the connection exists alreay you get the old handler from the factory.
精彩评论