public void sendMsg(Socket socket, String _user, string _msg) { sChat nowyChat = new sChat { username = _user, message = _msg }; socket.Emit("chat", JsonConvert.SerializeObject(nowyChat)); Console.WriteLine("Wyslano {0} : {1}", nowyChat.username, nowyChat.message); }
// CHAT SOCKETY public void chatGetMsg(Socket socket, String user) { sChat chat = new sChat(); socket.On("chat", (data) => { var sent = JsonConvert.DeserializeObject <sChat>(data.ToString()); chat.username = sent.username; chat.message = sent.message; if (!user.Equals(chat.username)) { Console.WriteLine("{0}: {1}", chat.username, chat.message); receivedMsg = chat.message; receivedFrom = chat.username; Login.main.Status = receivedFrom + ": " + receivedMsg + "\n"; } }); }