Exemple #1
0
        /// <summary>
        /// Registers a client connection with the matchmaker.
        /// </summary>
        /// <param name="client">The client's connection.</param>
        /// <returns>
        /// An unique identifier token for this client instance.
        /// </returns>
        public uint RegisterClient(ClientConnection client)
        {
            uint token;
            while (true)
            {
                token = (uint)Matchmaker.randomNumberGenerator.Next(
                    int.MinValue,
                    int.MaxValue);
                try
                {
                    lock (this.waitingClients)
                    {
                        this.waitingClients.Add(token, client);
                    }

                    break;
                }
                catch (ArgumentException)
                {
                    continue;
                }
            }

            return token;
        }
Exemple #2
0
 /// <summary>
 /// Handles successfully accepted client connections.
 /// </summary>
 /// <param name="accepted">
 /// The socket for the newly accepted connection.
 /// </param>
 private void ClientConnectionAccepted(Socket accepted)
 {
     ClientConnection connection = new ClientConnection(
         accepted,
         this.matchmaker);
 }
Exemple #3
0
 /// <summary>
 /// Starts a new forwarding agent to bi-directionally transfer data
 /// between an existing client connection and an existing service
 /// connection.
 /// </summary>
 /// <param name="client">The client connection.</param>
 /// <param name="service">The service connection.</param>
 public void InitiateForwarding(
     ClientConnection client,
     ServiceConnection service)
 {
     // -
     // Initiate bi-directional forwarding.
     // -
     Forwarder forwarder = new Forwarder(
         client.Socket,
         service.Socket,
         this.MatchEnding);
     lock (this.matches)
     {
         this.matches.Add(forwarder);
     }
 }