public void OffLine() { Console.WriteLine("{0} is offline!", uName); var uu = LoginUsers.Find(a => a.UserName == uName); if (uu != null) { LoginUsers.Remove(uu); } if (DicUserSockets.ContainsKey(uName)) { DicUserSockets.Remove(uName); } var userService = new UserService(uName); var theFriends = userService.GetFriends(); foreach (var f in theFriends) { if (DicUserSockets.ContainsKey(f.UserName)) { LogoutMsg logout = new LogoutMsg(uName); var sock = DicUserSockets[f.UserName]; logout.Send(sock); } } }
private void Logout() { UserService.LoginOk = false; LogoutMsg msg = new LogoutMsg(UserService.LoginUserName); msg.Send(serverSock); Console.WriteLine(">Logout successfully!"); }
private void LogOut_Button_Click(object sender, EventArgs e) { LogoutMsg logoutMessage = new LogoutMsg(); MemoryStream outStream = logoutMessage.WriteData(); m_Server.Send(outStream.GetBuffer()); AddActionText("Logged Out."); Application.Restart(); Environment.Exit(0); }
// Logout MSG private LogoutMsg GetLoMSG(byte[] msg, Int64 msgSize) { Int32 type = ByteInt32(msg[8]); byte[] seq_num = new byte[4]; byte[] vars = new byte[msgSize - 13]; Array.Copy(msg, 9, seq_num, 0, 4); Array.Copy(msg, 13, vars, 0, msgSize - 13); LogoutMsg LoMSG = LoMSGVars(vars); LoMSG.msgType = type; return(LoMSG); }
public void Process(Socket workerSock) { LogoutMsg msg = new LogoutMsg(); msg.ReceiveFrom(workerSock); //var logoutUser = UserService.LoginUsers.Find(u => u.UserName == msg.UserName); //UserService.LoginUsers.Remove(logoutUser); //if (UserService.DicUserSockets.ContainsKey(logoutUser.UserName)) // UserService.DicUserSockets.Remove(logoutUser.UserName); //Console.WriteLine("User 【{0}】 logout", msg.UserName); var userService = new UserService(msg.UserName); userService.OffLine(); }
public void Process(Socket workerSock) { LogoutMsg msg = new LogoutMsg(); msg.ReceiveFrom(workerSock); Console.WriteLine("Friend 【{0}】 offline", msg.UserName); if (UserService.CurrentUsersFriend == null) { return; } var uu = UserService.CurrentUsersFriend.Find(u => u.UserName == msg.UserName); if (uu != null) { uu.IPEnd = null; } }
private LogoutMsg LoMSGVars(byte[] from) { LogoutMsg msg = new LogoutMsg(ByteInt32(from)); return(msg); }
public byte[] SerializeMSG(LogoutMsg msg) { byte[] header = Header(msg.msgType); byte[] body = BuildMSG(msg.from); return(Combine(IntByte((Int64)8 + header.Length + body.Length), header, body)); }