Represents a player connected to the server.
Наследование: NetEntity
Пример #1
0
        /// <summary>
        /// Event handler for TCP connections.
        /// </summary>
        private void TCP_SocketConnected(Socket socket)
        {
            //Keep going until we find an ID for them
            while (true)
            {
                //Generate an ID
                int worldID = m_rng.Next();

                //See if it's unique
                if (!m_entities.ContainsKey(worldID))
                {
                    //Add them in
                    ServerEntity entity = new ServerEntity(socket, worldID, this, m_asyncPool);
                    if (m_entities.TryAdd(worldID, entity))
                    {
                        //DONE!
                        Console.WriteLine(worldID.ToString() + " joined");
                        break;
                    }
                }
            }
        }