def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = test_pb2_grpc.GreeterStub(channel)

        response = stub.SayHello(test_pb2.HelloRequest(name='nujnus'))
        print("Greeter client received: " + response.message)

        response = stub.SayHelloAgain(test_pb2.HelloRequest(name='dream'))
#                        SayHelloAgain
        print("Greeter client received: " + response.message)

    print("Greeter client received: " + response.message)
Пример #2
0
def run():
    channel = grpc.insecure_channel('[::]:50000')

    # Test/hello method
    server = test_pb2_grpc.TestStub(channel)
    data = test_pb2.HelloRequest(id=1234567890, name='Karotka testuje')
    response = server.hello(data)
    print("%s <= was received from the server" % response)

    # Login/login method
    server = test_pb2_grpc.LoginStub(channel)
    data = test_pb2.LoginRequest(username='******',
                                 password='******')
    response = server.login(data)
    print("%s <= was received from the server" % response)
Пример #3
0
def send(data):
    global client
    response = client.SayHello(test_pb2.HelloRequest(name="qrcode", sex=data))
    print("received: " + response.message)
Пример #4
0
def rpc_server_test_hello(uid, msg, req):
    pbHelloRequest = test_pb2.HelloRequest()  
    pbHelloRequest.ParseFromString(buff)
    print(pbHelloRequest.greeting)
    rpc_server_test_hello(uid, msg, req):
Пример #5
0
import test_pb2
import test_pb2_grpc

import pdb

config = yaml.load(
    open(os.path.join(os.path.dirname(__file__), '..', 'config',
                      'client.yml')))['endpoint']

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='GRPC client for test')
    parser.add_argument('-u',
                        '--username',
                        action='store',
                        nargs=None,
                        const=None,
                        default=None,
                        type=str,
                        choices=None,
                        required=True,
                        help='Please input a username.')
    arguments = parser.parse_args()

    with grpc.insecure_channel(':'.join([config['host'],
                                         str(config['port'])])) as channel:
        stub = test_pb2_grpc.GreeterStub(channel)
        response = stub.SayHello(
            test_pb2.HelloRequest(name=arguments.username))

    print(response.message)