Esempio n. 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            HelloService.HelloServiceClient cl = new HelloService.HelloServiceClient("BasicHttpBinding_IHelloService");
            cl.UrlIsValid(url);

            HelloService.HelloServiceClient client = new HelloService.HelloServiceClient("BasicHttpBinding_IHelloService");
            Label1.Text = client.ProcessDataAdd(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, url);

            Label8.Text = url;
         //   BindData();
         
        }
Esempio n. 2
0
        public static async Task SingleReverse(HelloService.HelloServiceClient client)
        {
            var call = client.SayHelloSingleReverse();

            for (int i = 0; i < 50; i++)
            {
                await call.RequestStream.WriteAsync(new HelloMessage.HelloMessageRequest()
                {
                    Name = "tim lv" + i.ToString()
                });
            }
            await call.RequestStream.CompleteAsync();

            var msg = await call.ResponseAsync;

            Console.WriteLine(msg);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                throw new InvalidOperationException("args.Length must be 2 but is " + args.Length);
            }
            var command = args[0];
            var port    = 8088;

            if (command.ToLower() == "server")
            {
                Server server = new Server
                {
                    Services = { HelloService.BindService(new HelloServiceImpl()) },
                    Ports    = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
                };
                server.Start();

                Console.WriteLine("RouteGuide server listening on port " + port);
                Console.WriteLine("Press any key to stop the server...");
                Console.ReadKey();

                server.ShutdownAsync().Wait();
            }
            else if (command.ToLower() == "client")
            {
                Channel channel = new Channel($"localhost:{port}", ChannelCredentials.Insecure);
                var     client  = new HelloService.HelloServiceClient(channel);

                // YOUR CODE GOES HERE
                var reply = client.SayHello(new HelloRequest
                {
                    Name = "jiannan"
                });

                Console.WriteLine("Reply: " + reply.Message);
                channel.ShutdownAsync().Wait();
            }
            else
            {
                throw new InvalidOperationException("do not support command: " + command);
            }
        }
Esempio n. 4
0
        private static async Task ServerStreamingCallExample(HelloService.HelloServiceClient client)
        {
            var cts = new CancellationTokenSource();

            cts.CancelAfter(TimeSpan.FromSeconds(3.5));

            using var call = client.SayHellos(new HelloRequest { Name = "啦啦啦" }, cancellationToken: cts.Token);

            try
            {
                await foreach (var message in call.ResponseStream.ReadAllAsync())
                {
                    Console.WriteLine("Greeting: " + message.Message);
                }
            }
            catch (RpcException ex) when(ex.StatusCode == StatusCode.Cancelled)
            {
                Console.WriteLine("Stream cancelled.");
            }
        }
Esempio n. 5
0
    public void Connect(string serverIP)
    {
        try
        {
            _Channel = new Channel($"{serverIP}", ChannelCredentials.Insecure);

            _HelloServiceClient = new HelloService.HelloServiceClient(_Channel);

            var helloReply = _HelloServiceClient.SayHello(new HelloRequest {
                Message = "Hello server!"
            });

            DontDestroyOnLoad(gameObject);
            SceneManager.LoadScene("PlayScene");

            Debug.Log($"reply from server : {helloReply.Message}");
        }
        catch (Exception exception)
        {
            Debug.Log(exception.Message);
        }
    }
Esempio n. 6
0
 public ActionResult Index(string userName)
 {
     HelloService.HelloServiceClient client = new HelloService.HelloServiceClient("BasicHttpBinding_IHelloService");
     ViewBag.Message = client.GetMessage(userName);
     return(View());
 }
Esempio n. 7
0
 static HelloClient()
 {
     _channel = new Channel("localhost:8088", ChannelCredentials.Insecure);
     _client  = new HelloService.HelloServiceClient(_channel);
 }
Esempio n. 8
0
 private async void button1_Click(object sender, EventArgs e)
 {
     HelloService.HelloServiceClient client = new HelloService.HelloServiceClient();
     label1.Text = await client.GetMessageAsync(textBox1.Text);
 }
Esempio n. 9
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     HelloService.HelloServiceClient client = new HelloService.HelloServiceClient("BasicHttpBinding_IHelloService");
     Label1.Text = client.GetMessage(TextBox1.Text);
 }
Esempio n. 10
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     HelloService.HelloServiceClient client = new HelloService.HelloServiceClient("BasicHttpBinding_IHelloService");
     Label1.Text = client.GetMessage(TextBox1.Text);
 }
Esempio n. 11
0
 private void button1_Click(object sender, EventArgs e)
 {
     HelloService.HelloServiceClient cl = new HelloService.HelloServiceClient("NetTcpBinding_IHelloService");
     label1.Text = cl.GetMessage(textBox1.Text);
 }
Esempio n. 12
0
        private static async Task UnaryCallExample(HelloService.HelloServiceClient client)
        {
            var reply = await client.SayHelloAsync(new HelloRequest { Name = "哈哈哈" });

            Console.WriteLine("Greeting: " + reply.Message);
        }