private void UserJoinHandler(byte[] data) { UserJoin userJoin = NetworkUtils.Deserialize <UserJoin>(data); Application.Current.Dispatcher.BeginInvoke(new Action(() => { UserJoinEvent?.Invoke(userJoin); })); }
private void Connector_LoginEvent(object sender, LoginEventArgs e) { Account account = GetAccount(e.UserID); if (account == null) { connector.SendLoginResult(new UserSocket(e.UserID, " ", e.ReceiveSocket), false); return; } UserSocket newUserSocket = new UserSocket(account.UserID, account.NickName, e.ReceiveSocket); if (account.ConfirmPassword(e.PassWord) && GetUserSocket(e.UserID) == null) { connector.SendLoginResult(newUserSocket, true); //connector.SendUserChange(newUserSocket, newUserSocket.ToUser(), CommandType.UserJoin); //向已登录的用户发送新登录用户的信息 foreach (UserSocket oldUser in LoginedUserList) { connector.SendUserChange(oldUser, newUserSocket.ToUser(), CommandType.UserJoin); } //向新登录用户发送已登录的用户的信息 foreach (UserSocket oldUser in LoginedUserList) { connector.SendUserChange(newUserSocket, oldUser.ToUser(), CommandType.UserJoin); } LoginedUserList.Add(newUserSocket); UserJoinEvent?.Invoke(this, new User(newUserSocket.UserID, newUserSocket.NickName)); return; } else { connector.SendLoginResult(newUserSocket, false); return; } }