示例#1
0
        private void InitializeGrpc()
        {
            var channel = new Channel(Host + ":" + Port, ChannelCredentials.Insecure);

            // Create a client with the channel
            var chatService = new ChatService.ChatServiceClient(channel);

            // Open a connection to server
            _call = chatService.chat();
        }
示例#2
0
 private async void ChatForm_Load(object sender, EventArgs e)
 {
     try
     {
         // Open a connection to the server
         using (var call = _chatService.chat())
         {
             while (await call.ResponseStream.MoveNext(CancellationToken.None))
             {
                 var serverMessage      = call.ResponseStream.Current;
                 var otherClientMessage = serverMessage.Message;
                 var displayMessage     = string.Format("{0}:{1}{2}", otherClientMessage.From, otherClientMessage.Message, Environment.NewLine);
                 chatTextBox.Text += displayMessage;
             }
         }
     }
     catch (RpcException)
     {
         throw;
     }
 }