Exemplo n.º 1
0
    def start(self, argv):
        # client obj start
        if (len(argv) < 3):
            raise ValueError(
                'wrong usage: EchoServiceClient server-host server-port')

        self.__server = RpcAddress()
        addr = Clientlet.build_address(argv[1], int(argv[2]))
        self.__server.set_addr(addr)
        self.__echo_client = EchoClient(self.__server)
        self.__task = Clientlet.call_async(LPC_ECHO_TIMER2, self, self.timer,
                                           0, 0, 1000)
        return ERR_OK.get_err()
Exemplo n.º 2
0
class EchoServiceClient(ServiceApp):
    __server = None
    __echo_client = None
    __task = None

    def start(self, argv):
        # client obj start
        if(len(argv) < 3):
            raise ValueError('wrong usage: EchoServiceClient server-host server-port')

        self.__server = RpcAddress()
        addr = Clientlet.build_address(argv[1], int(argv[2]))
        self.__server.set_addr(addr)
        self.__echo_client = EchoClient(self.__server)
        self.__task = Clientlet.call_async(LPC_ECHO_TIMER2, self, self.timer, 0, 0, 1000)
        return ERR_OK.get_err()

    def stop(self, cleanup = 0):
        Clientlet.cancel_task(self.__task, cleanup)
        self.__echo_client = None

    def timer(self):
        time.sleep(1)
        rpc_stream = RpcStream()
        rpc_stream.write('f', 12.345678)
        rpc_stream.write('6s', b'ahaaaa')		
        print('sync_resp_data: call ')
		
        request_content = rpc_stream.get_content()
        # async pattern
        #self.__echo_client.echo_async(request_content)
        # sync pattern
        print('sync_resp_data: return ', self.__echo_client.echo_sync(request_content))
        return
Exemplo n.º 3
0
    def start(self, argv):
        # client obj start
        if(len(argv) < 3):
            raise ValueError('wrong usage: EchoServiceClient server-host server-port')

        self.__server = RpcAddress()
        addr = Clientlet.build_address(argv[1], int(argv[2]))
        self.__server.set_addr(addr)
        self.__echo_client = EchoClient(self.__server)
        self.__task = Clientlet.call_async(LPC_ECHO_TIMER2, self, self.timer, 0, 0, 1000)
        return ERR_OK.get_err()
Exemplo n.º 4
0
class EchoServiceClient(ServiceApp):
    __server = None
    __echo_client = None
    __task = None

    def start(self, argv):
        # client obj start
        if (len(argv) < 3):
            raise ValueError(
                'wrong usage: EchoServiceClient server-host server-port')

        self.__server = RpcAddress()
        addr = Clientlet.build_address(argv[1], int(argv[2]))
        self.__server.set_addr(addr)
        self.__echo_client = EchoClient(self.__server)
        self.__task = Clientlet.call_async(LPC_ECHO_TIMER2, self, self.timer,
                                           0, 0, 1000)
        return ERR_OK.get_err()

    def stop(self, cleanup=0):
        Clientlet.cancel_task(self.__task, cleanup)
        self.__echo_client = None

    def timer(self):
        time.sleep(1)
        rpc_stream = RpcStream()
        rpc_stream.write('f', 12.345678)
        rpc_stream.write('6s', b'ahaaaa')
        print('sync_resp_data: call ')

        request_content = rpc_stream.get_content()
        # async pattern
        #self.__echo_client.echo_async(request_content)
        # sync pattern
        print('sync_resp_data: return ',
              self.__echo_client.echo_sync(request_content))
        return