Exemplo n.º 1
0
    def _startup_svc(self):
        # Create service
        svc = Service('customheaderparts_test_svc',
                      Service.RAW if self._is_raw else Service.NORMAL)

        # Create facade
        facade = _Facade(self._as_client, self._test_type)
        svc.registerfacade(facade)

        svc_type_repr = 'RAW' if self._is_raw else 'NORMAL'
        if self._as_client:
            while True:
                try:
                    session_id = svc.connect(self._ip, self._port)
                except (Exception, ), e:
                    print 'Connect to {}:{} failed, will continue to try...'.format(self._ip, self._port)
                else:
                    print 'Service[{}] connected to {}:{}, session_id: {}' \
                        .format(svc_type_repr, self._ip, self._port, session_id)
                    break
Exemplo n.º 2
0
    def _startup_svc(self):
        # Create service
        svc = Service('customheaderparts_test_svc',
                      Service.RAW if self._is_raw else Service.NORMAL)

        # Create facade
        facade = _Facade(self._as_client, self._test_type)
        svc.registerfacade(facade)

        svc_type_repr = 'RAW' if self._is_raw else 'NORMAL'
        if self._as_client:
            while True:
                try:
                    session_id = svc.connect(self._ip, self._port)
                except (Exception, ), e:
                    print 'Connect to {}:{} failed, will continue to try...'.format(
                        self._ip, self._port)
                else:
                    print 'Service[{}] connected to {}:{}, session_id: {}' \
                        .format(svc_type_repr, self._ip, self._port, session_id)
                    break
Exemplo n.º 3
0
    def run(self, arg):
        print 'multi service test:'

        client = Service('multisvc_test_client')
        server = Service('multisvc_test_server')

        client.codec = Service.CODEC_JSON
        server.codec = Service.CODEC_JSON

        client.registerfacade(ClientFacade())
        server.registerfacade(ServerFacade())

        client.subscribe(TEST_RES, ClientPacketHandler())
        server.subscribe(TEST_REQ, ServerPacketHandler())

        #        client.presubscribe(TEST_RES, ClientPacketPreHandler())
        #        server.presubscribe(TEST_REQ, ServerPacketPreHandler())

        try:
            client.unify_presubscribe(ClientPacketUnifyPreHandler())
            server.unify_presubscribe(ServerPacketUnifyPreHandler())
        except llbc.error, e:
            print 'subscribe unify pre-handler to service failed'
            print 'reason: {}'.format(e)
Exemplo n.º 4
0
    def run(self, arg):
        print 'multi service test:'

        client = Service('multisvc_test_client')
        server = Service('multisvc_test_server')

        client.codec = Service.CODEC_JSON
        server.codec = Service.CODEC_JSON

        client.registerfacade(ClientFacade())
        server.registerfacade(ServerFacade())

        client.subscribe(TEST_RES, ClientPacketHandler())
        server.subscribe(TEST_REQ, ServerPacketHandler())

#        client.presubscribe(TEST_RES, ClientPacketPreHandler())
#        server.presubscribe(TEST_REQ, ServerPacketPreHandler())

        try:
            client.unify_presubscribe(ClientPacketUnifyPreHandler())
            server.unify_presubscribe(ServerPacketUnifyPreHandler())
        except llbc.error, e:
            print 'subscribe unify pre-handler to service failed'
            print 'reason: {}'.format(e)