public void CloseForm() { SignUpEvent.Invoke(this, new SignUpEventArgs() { CloseSignUpProcess = true }); }
private void MessageSorter(byte[] buffer, int start, int length, Socket clientSocket) { string content = Encoding.Default.GetString(buffer, 0, length); MessageDictionary messageD = new MessageDictionary(content); ShowMessage("从" + clientSocket.RemoteEndPoint.ToString() + "接收消息:" + content + "\n"); CommandType command = (CommandType)Enum.Parse(typeof(CommandType), messageD[MesKeyStr.CommandType]); switch (command) { case CommandType.Login: { LoginEvent?.Invoke(this, new LoginEventArgs() { UserID = messageD[MesKeyStr.UserID], PassWord = messageD[MesKeyStr.PassWord], ReceiveSocket = clientSocket }); break; } case CommandType.Logout: { LogoutEvent?.Invoke(this, new User(messageD[MesKeyStr.UserID], messageD[MesKeyStr.NickName])); break; } case CommandType.SignUp: { SignUpEvent?.Invoke(this, new SignUpEventArgs(clientSocket, messageD[MesKeyStr.NickName], messageD[MesKeyStr.PassWord])); break; } case CommandType.GroupMessage: { GroupMessageEvent?.Invoke(this, messageD); break; } case CommandType.PrivateMessage: { PrivateMessageEvent?.Invoke(this, messageD); break; } case CommandType.UserJoin: case CommandType.UserQuit: case CommandType.LoginResult: case CommandType.SignUpResult: case CommandType.ServerDisconnect: case CommandType.Remove: { ShowMessage("收到错误的消息类型!"); throw new Exception("收到错误的消息类型!"); } } }