Beispiel #1
0
            /// <summary>Initializes the newly connected client's TCP-related info.</summary>
            /// <param name="_socket">The TcpClient instance of the newly connected client.</param>
            public void Connect(TcpClient _socket)
            {
                socket = _socket;
                socket.ReceiveBufferSize = dataBufferSize;
                socket.SendBufferSize    = dataBufferSize;

                stream = socket.GetStream();

                receivedData  = new Packet();
                receiveBuffer = new byte[dataBufferSize];

                stream.BeginRead(receiveBuffer, 0, dataBufferSize, ReceiveCallback, null);

                Server.clients[id].clientUUID = Guid.NewGuid().ToString();

                ServerSend.TokenRequest(id, Server.clients[id].clientUUID);
            }
Beispiel #2
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);
                    }
                }
            }
        }