Example #1
0
 /// <summary>Disconnects the client and stops all network traffic.</summary>
 private void Disconnect()
 {
     Console.WriteLine($"{tcp.socket.Client.RemoteEndPoint} has disconnected.");
     LobbyRoomsManager.ExitRoom(id);
     clientUUID = "";
     tcp.Disconnect();
 }
Example #2
0
 public static void ExitRoom(int fromClient, Packet packet)
 {
     if (!Server.clients[fromClient].isTokenChecked)
     {
         Server.clients[fromClient].tcp.Disconnect();
         return;
     }
     LobbyRoomsManager.ExitRoom(fromClient);
 }
Example #3
0
        public static void LoginRoom(int fromClient, Packet packet)
        {
            if (!Server.clients[fromClient].isTokenChecked)
            {
                Server.clients[fromClient].tcp.Disconnect();
                return;
            }
            string roomUUID = packet.ReadString();

            LobbyRoomsManager.EnterRoom(fromClient, roomUUID);
        }
Example #4
0
 public void RemovePlayer(int playerIndex)
 {
     foreach (var player in players)
     {
         if (player.index == playerIndex)
         {
             players.Remove(player);
             if (players.Count > 0)
             {
                 UpdatePlayers();
             }
             else
             {
                 LobbyRoomsManager.CloseRoom(this);
             }
             break;
         }
     }
 }
Example #5
0
        public static void CreateRoom(int fromClient, Packet packet)
        {
            if (!Server.clients[fromClient].isTokenChecked)
            {
                Server.clients[fromClient].tcp.Disconnect();
                return;
            }
            string UUID = packet.ReadString();

            if (string.Equals(Server.clients[fromClient].UUID, UUID))
            {
                string roomName = packet.ReadString();
                if (roomName.Length > 1)
                {
                    roomName = roomName.Remove(roomName.Length - 1);
                    LobbyRoomsManager.CreateRoom(fromClient, roomName);
                    LobbyRoom room = LobbyRoomsManager.GetRoom(Server.clients[fromClient].UUID);
                    if (room != null)
                    {
                        ServerSend.RoomData(fromClient, room);
                    }
                }
            }
        }