Ejemplo n.º 1
0
 public static void WriteRankUpdate()
 {
     lock (Handle.OnlineUsers)
     {
         foreach (var client in Handle.OnlineUsers)
         {
             try
             {
                 Packets.YourRank(client.Value).Write(client.Key);
             }
             catch
             {
             }
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Loops through the logged in users dictionary, finds all clients with the specified user id, notifies the client with the specified reason, then closes the stream.
 /// </summary>
 /// <param name="userId">The id of the user that should have their logged in sessions disconnected</param>
 public static void DisconnectSessions(int userId)
 {
     lock (Handle.OnlineUsers)
     {
         var sessions = Handle.OnlineUsers.Where(a => a.Value.Id == userId).Select(a => a.Key);
         foreach (var session in sessions)
         {
             try
             {
                 Packets.LoginFail("Disconnected").Write(session);
                 session.TcpClient.Close();
             }
             catch
             {
             }
         }
     }
 }
Ejemplo n.º 3
0
        public static void ClientLeft(Client client)
        {
            lock (Program.ConnectedClients)
                if (!Program.ConnectedClients.Contains(client))
                {
                    Program.ConnectedClients.Add(client);
                }


            lock (OnlineUsers)
            {
                if (OnlineUsers.ContainsKey(client))
                {
                    Console.WriteLine("[Info] User {0} left", OnlineUsers[client].Email);
                    OnlineUsers.Remove(client);
                    Packets.UserList().WriteAll();
                }
                else
                {
                    Console.WriteLine("[Info] Client disconnected");
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Calls "Handle.PurgeCache" with the specified users id, writes a list update to all clients, and then writes a rank update to all users
 /// </summary>
 /// <param name="user"></param>
 private static void Purge(User user)
 {
     Handle.PurgeCache(user.Id);
     Packets.UserList().WriteAll();
     Program.WriteRankUpdate();
 }