public void updateMessageList(RichTextBox messageList, ludo_client.dto.Message newIncomingMessage) { if (messageList.InvokeRequired) { // We're on a thread other than the GUI thread messageList.Invoke(new MethodInvoker(() => updateMessageList(messageList, newIncomingMessage))); return; } String timeStampSecond = newIncomingMessage.TimeStamp.Second.ToString(); if (timeStampSecond.Length == 1) { timeStampSecond = "0" + timeStampSecond; } String timeStamp = "[" + newIncomingMessage.TimeStamp.ToShortTimeString() + ":" + timeStampSecond + "]"; String sender = newIncomingMessage.Sender.UserName; String message = newIncomingMessage.Msg; messageList.AppendText(timeStamp + " ", Color.Gray); messageList.AppendText(sender + ": " , Color.Blue); messageList.AppendText(message + "\n"); messageList.ScrollToCaret(); }
private int setMessageTargetID(ludo_client.dto.Message message) { if (this.chatTabControl.SelectedIndex > 0) { return Main.ludo.Users[ClientBase.myUserListIndex].CurrentRoomID; // room chat } else { return -1; // global server chat } }
public void sendMessage(ludo_client.dto.Message message) { websocket.Send(JsonConvert.SerializeObject(message)); }