private void OnSignalReceived(ChatroomSignalEventArgs e) { if (e.Signal.StartsWith(ChatroomService.ParticipantStartedTypingMessage)) { string stringId = e.Signal.Substring(ChatroomService.ParticipantStartedTypingMessage.Length + 1); int id = int.Parse(stringId); ChatroomParticipant participant = this.chatroomService.GetParticipant(id); this.typingParticipants.Add(participant); } else if (e.Signal.StartsWith(ChatroomService.ParticipantFinishedTypingMessage)) { string stringId = e.Signal.Substring(ChatroomService.ParticipantFinishedTypingMessage.Length + 1); int id = int.Parse(stringId); ChatroomParticipant participant = this.chatroomService.GetParticipant(id); this.typingParticipants.Remove(participant); } else if (e.Signal.StartsWith(ChatroomService.ParticipantTextedMessage)) { string stringIdAndMessage = e.Signal.Substring(ChatroomService.ParticipantTextedMessage.Length + 1); string stringId = stringIdAndMessage.Substring(0, stringIdAndMessage.IndexOf(" ")); int id = int.Parse(stringId); ChatroomParticipant participant = this.chatroomService.GetParticipant(id); string message = e.Signal.Substring(ChatroomService.ParticipantTextedMessage.Length + stringId.Length + 2); this.Items.Add(new ChatroomTextMessage { Sender = participant, Message = message, }); } }
private void ChatroomService_Signal(object sender, ChatroomSignalEventArgs e) { Device.BeginInvokeOnMainThread(() => this.OnSignalReceived(e)); }