예제 #1
0
    def __init__(self, loop, url, debug=False):
        super(DDPClient, self).__init__()
        ids = build_id_generator()
        self._board = board = pubsub.MessageBoard(loop)
        self._caller = pubsub.MethodCaller(board, MethodMessageFactory(ids))
        factory = WebSocketClientFactory(url=url, loop=loop)
        factory.protocol = pubsub.SocketPublisherFactory(board)
        subscribers = [
            self._caller,
            pubsub.DDPConnector(board),
            pubsub.Ponger(board),
            pubsub.Outbox(board),
            pubsub.SocketReconnector(board),
            pubsub.SocketConnector(board, loop, factory),

            pubsub.MessageParser(board, AddedBeforeMessageParser()),
            pubsub.MessageParser(board, AddedMessageParser()),
            pubsub.MessageParser(board, ChangedMessageParser()),
            pubsub.MessageParser(board, ConnectedMessageParser()),
            pubsub.MessageParser(board, ErrorMessageParser()),
            pubsub.MessageParser(board, FailedMessageParser()),
            pubsub.MessageParser(board, MovedBeforeMessageParser()),
            pubsub.MessageParser(board, NosubMessageParser()),
            pubsub.MessageParser(board, PingMessageParser()),
            pubsub.MessageParser(board, PongMessageParser()),
            pubsub.MessageParser(board, ReadyMessageParser()),
            pubsub.MessageParser(board, RemovedMessageParser()),
            pubsub.MessageParser(board, ResultMessageParser()),
            pubsub.MessageParser(board, UpdatedMessageParser()),

            pubsub.MessageSerializer(board, ConnectMessageSerializer()),
            pubsub.MessageSerializer(board, MethodMessageSerializer()),
            pubsub.MessageSerializer(board, PingMessageSerializer()),
            pubsub.MessageSerializer(board, PongMessageSerializer()),
            pubsub.MessageSerializer(board, SubMessageSerializer()),
            pubsub.MessageSerializer(board, UnsubMessageSerializer()),

            pubsub.PodMessageFilter(board, PodMessageFilter()),
            pubsub.PodMessageParser(board, PodMessageParser()),
            pubsub.PodMessageSerializer(board, PodMessageSerializer()),
        ]

        if debug:
            subscribers.append(pubsub.Logger(board))

        for subscriber in subscribers:
            subscriber.subscribe()
예제 #2
0
파일: client.py 프로젝트: zhouzhuojie/pyddp
    def __init__(self, url, logging=False):
        socket_factory = ObservableWebSocketClientFactory(ServerUrl(url))
        id_generator = build_id_generator()

        self._board = board = pubsub.MessageBoard()
        self._caller = pubsub.MethodCaller(board, id_generator)

        self._components = [
            self._caller,
            pubsub.Connection(board),
            pubsub.Ponger(board),
            pubsub.Reconnector(board),
            pubsub.SocketConnection(board, socket_factory),

            pubsub.MessageParser(board, AddedBeforeMessageParser()),
            pubsub.MessageParser(board, AddedMessageParser()),
            pubsub.MessageParser(board, ChangedMessageParser()),
            pubsub.MessageParser(board, ConnectedMessageParser()),
            pubsub.MessageParser(board, ErrorMessageParser()),
            pubsub.MessageParser(board, FailedMessageParser()),
            pubsub.MessageParser(board, MovedBeforeMessageParser()),
            pubsub.MessageParser(board, NosubMessageParser()),
            pubsub.MessageParser(board, PingMessageParser()),
            pubsub.MessageParser(board, PongMessageParser()),
            pubsub.MessageParser(board, ReadyMessageParser()),
            pubsub.MessageParser(board, RemovedMessageParser()),
            pubsub.MessageParser(board, ResultMessageParser()),
            pubsub.MessageParser(board, UpdatedMessageParser()),

            pubsub.MessageSerializer(board, ConnectMessageSerializer()),
            pubsub.MessageSerializer(board, MethodMessageSerializer()),
            pubsub.MessageSerializer(board, PingMessageSerializer()),
            pubsub.MessageSerializer(board, PongMessageSerializer()),
            pubsub.MessageSerializer(board, SubMessageSerializer()),
            pubsub.MessageSerializer(board, UnsubMessageSerializer()),

            pubsub.PodMessageFilter(board, PodMessageFilter()),
            pubsub.PodMessageParser(board, PodMessageParser()),
            pubsub.PodMessageSerializer(board, PodMessageSerializer()),
        ]

        if logging:
            self._components.append(pubsub.Logger(board))
예제 #3
0
파일: client.py 프로젝트: zhouzhuojie/pyddp
    def __init__(self, url, logging=False):
        socket_factory = ObservableWebSocketClientFactory(ServerUrl(url))
        id_generator = build_id_generator()

        self._board = board = pubsub.MessageBoard()
        self._caller = pubsub.MethodCaller(board, id_generator)

        self._components = [
            self._caller,
            pubsub.Connection(board),
            pubsub.Ponger(board),
            pubsub.Reconnector(board),
            pubsub.SocketConnection(board, socket_factory),
            pubsub.MessageParser(board, AddedBeforeMessageParser()),
            pubsub.MessageParser(board, AddedMessageParser()),
            pubsub.MessageParser(board, ChangedMessageParser()),
            pubsub.MessageParser(board, ConnectedMessageParser()),
            pubsub.MessageParser(board, ErrorMessageParser()),
            pubsub.MessageParser(board, FailedMessageParser()),
            pubsub.MessageParser(board, MovedBeforeMessageParser()),
            pubsub.MessageParser(board, NosubMessageParser()),
            pubsub.MessageParser(board, PingMessageParser()),
            pubsub.MessageParser(board, PongMessageParser()),
            pubsub.MessageParser(board, ReadyMessageParser()),
            pubsub.MessageParser(board, RemovedMessageParser()),
            pubsub.MessageParser(board, ResultMessageParser()),
            pubsub.MessageParser(board, UpdatedMessageParser()),
            pubsub.MessageSerializer(board, ConnectMessageSerializer()),
            pubsub.MessageSerializer(board, MethodMessageSerializer()),
            pubsub.MessageSerializer(board, PingMessageSerializer()),
            pubsub.MessageSerializer(board, PongMessageSerializer()),
            pubsub.MessageSerializer(board, SubMessageSerializer()),
            pubsub.MessageSerializer(board, UnsubMessageSerializer()),
            pubsub.PodMessageFilter(board, PodMessageFilter()),
            pubsub.PodMessageParser(board, PodMessageParser()),
            pubsub.PodMessageSerializer(board, PodMessageSerializer()),
        ]

        if logging:
            self._components.append(pubsub.Logger(board))
예제 #4
0
 def setUp(self):
     self.factory = MethodMessageFactory(build_id_generator())
예제 #5
0
 def setUp(self):
     self.id_generator = build_id_generator()
예제 #6
0
 def setUp(self):
     self.id_generator = build_id_generator()