开发者

Twisted factory protocol instance based callback

开发者 https://www.devze.com 2023-01-19 06:54 出处:网络
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 d

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消