public void ReadCallback(string message) { SocketAction socketAction = SocketAction.Deserialize(message); switch (socketAction.SocketActions) { case SocketActions.ClientLogin: Username = socketAction.Message; Console.WriteLine($"Welcome {Username}!"); Program.Server.JoinRoom(Username, Roomname); break; case SocketActions.ClientChat: if (Roomname != socketAction.Message) { Program.Server.LeaveRoom(Username, Roomname); Roomname = socketAction.Message; Program.Server.JoinRoom(Username, Roomname); } break; case SocketActions.ClientGoodbye: Close(); break; case SocketActions.ClientSendMessage: MessageControl(socketAction.Message); break; } }
public async Task <int> SendMessage(SocketAction message) { await StreamWriter.WriteLineAsync(message.Serialize()); await StreamWriter.FlushAsync(); return(1); }