示例#1
0
        static async Task Main(string[] args)
        {
            // Build Netifi Broker Connection
            var accessKey   = 9007199254740991;
            var accessToken = "kTBDVtfRBO4tHOnZzSyY5ym2kfY=";
            var transport   = new SocketTransport("tcp://localhost:8001/");
            var client      = new Broker.Client.BrokerClient(accessKey, accessToken, null, null, "quickstart.clients", "client", 0, new SortedDictionary <string, string>(), transport, RSocketOptions.Default);

            // Connect to Netifi Platform
            await client.ConnectAsync();

            // Create Client to Communicate with the HelloService (included example service)
            var group        = client.Group("quickstart.services.helloservices", new SortedDictionary <string, string>());
            var helloService = new HelloService.HelloServiceClient(group);

            // Create Request to HelloService
            var request = new HelloRequest();

            request.Name = "World";

            Console.WriteLine("Sending 'World' to HelloService...");

            // Call the HelloService
            var response = await helloService.SayHello(request, new ReadOnlySequence <byte>());

            Console.WriteLine(response.Message);
        }
示例#2
0
        static async Task Main(string[] args)
        {
            var serviceName = "helloservice-" + Guid.NewGuid().ToString();

            // Build Netifi Broker Connection
            var accessKey   = 9007199254740991;
            var accessToken = "kTBDVtfRBO4tHOnZzSyY5ym2kfY=";
            var transport   = new SocketTransport("tcp://localhost:8001/");
            var client      = new Broker.Client.BrokerClient(accessKey, accessToken, null, null, "quickstart.services.helloservices", "helloservice", 0, new SortedDictionary <string, string>(), transport, RSocketOptions.Default);

            // Add Service to Respond to Requests
            var service = new DefaultHelloService();

            client.AddService(service);

            // Connect to Netifi Platform
            await client.ConnectAsync();

            // Keep the Service Running
            await Task.Delay(Timeout.Infinite);
        }