Exemplo n.º 1
0
        private async void UpdateChat()
        {
            var chat = new ChatService.ChatServiceClient(channel);

            try
            {
                using (stream = chat.chatStream())
                {
                    while (await stream.ResponseStream.MoveNext(CancellationToken.None))
                    {
                        //var serverMessage = stream.ResponseStream.Current;

                        //var displayMessage = string.Format("{0}:{1}{2}", serverMessage.Name, serverMessage.Textmessage, Environment.NewLine);
                        //chatbox.Text += displayMessage;

                        var serverMessage      = stream.ResponseStream.Current;
                        var otherClientMessage = serverMessage.Textmessage;
                        var displayMessage     = string.Format("{0}:{1}{2}", otherClientMessage.From, otherClientMessage.Message, Environment.NewLine);
                        chatbox.Text += displayMessage;
                    }
                }
            }
            catch (RpcException)
            {
                stream = null;
                throw;
            }
        }