예제 #1
0
 public void addUser(User user)
 {
     user.setLobby(this);
     Users.Add(user);
     //user.SendMessageToUser("Welcome!");
     user.SendMessageToUser("FILELIST" + esc + "exponential" + esc + "quadratic" + esc + "fibonacci\n");
     user.socket.BeginReceive(user.LineReceivedFromUser, user.socket);
 }
예제 #2
0
 /// <summary>
 /// If one of the player sockets  closes, then they will send
 /// themselves to this method, saying the game needs to be
 /// terminated.  Sends a message to the remaining player letting
 /// them know and closes the game.
 /// </summary>
 /// <param name="u"></param>
 public void SessionTerminated(User u)
 {
     lock (Lock)
     {
         if (ReferenceEquals(user.socket, null) && (ReferenceEquals(user.socket, null)))
             return;
         if (ReferenceEquals(u, user))
         {
             user.TerminatePlayer();
         }
         else
         {
             user.TerminatePlayer();
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Finds the player that clicked cancel and removes them from the queue.
        /// </summary>
        private bool PlayerCancel(User p)
        {
            //// Get the first player in the queue and check if they are the one that
            //// clicked cancel.
            //Player first = players.Dequeue();
            //if (ReferenceEquals(first, p))
            //{
            //    // TODO: socket might not exist anymore
            //    first.socket.CloseSocket();
            //    return true;
            //}
            //// First player wasn't the one, so put them back in the queue
            //players.Enqueue(first);

            //// Loop through and find the player that clicked cancel
            //while (true)
            //{
            //    Player temp = players.Dequeue();
            //    if (ReferenceEquals(temp, p))
            //    {
            //        temp.socket.CloseSocket();
            //        break;
            //    }
            //    players.Enqueue(temp);
            //}

            //// Loop through and put the first player at the front of the queue
            //while (true)
            //{
            //    Player temp = players.Peek();
            //    if (ReferenceEquals(temp, first))
            //        break;

            //    // Take the person in front and move them to the back
            //    temp = players.Dequeue();
            //    players.Enqueue(temp);
            //}

            return true;
        }