示例#1
0
    def _register_connection_handlers(self):
        self.connection.register_raw_handler(
            PersistentHandler(self.on_connection_message))

        self.connection.register_handler(
            EventMessageHandler(self.handle_event_message))
        self.connection.register_handler(
            ErrorMessageHandler(self.handle_error_message))
示例#2
0
文件: paradox.py 项目: psyciknz/pai
    def __init__(self,
                 connection: Connection,
                 interface: InterfaceManager,
                 retries=3):

        self.panel = None  # type: Panel
        self.connection = connection
        self.retries = retries
        self.message_manager = AsyncMessageManager()
        self.work_loop = asyncio.get_event_loop() # type: asyncio.AbstractEventLoop
        self.receive_worker_task = None

        self.message_manager.register_handler(EventMessageHandler(self.handle_event))
        self.message_manager.register_handler(ErrorMessageHandler(self.handle_error))

        self.data = defaultdict(Type)  # dictionary of Type
        self.reset()