Пример #1
0
 /// <summary>
 ///     Constructs a new instance of this class.
 /// </summary>
 /// <param name="client">Game client that this peer is connected to.</param>
 /// <param name="peer_connection">Connection through which this peer is connected.</param>
 public GameClientPeer(GameClientService client, Connection peer_connection)
 {
     m_gameClient = client;
     m_connection = peer_connection;
 }
        /// <summary>
        ///     Provides the functionality for this thread.
        /// </summary>
        protected override void EntryPoint()
        {
            Logger.Info("Starting new game client on thread #{0}.", LoggerVerboseLevel.High, Thread.CurrentThread.ManagedThreadId);

            // Setup the service.
            m_service = new GameClientService(m_settings, m_arbitratorHost, m_arbitratorPort);
            m_service.Initialize();

            // Calculate when our life is over.
            m_lifeOverTimer = Environment.TickCount + RandomHelper.RandomInstance.Next(m_settings.ClientLifetimeMin, m_settings.ClientLifetimeMax);

            bool connectedLastFrame = false;

            // Keep running until the service finishes or we are aborted.
            while (m_aborting == false)
            {
                // Are we out of time?
                if (Environment.TickCount > m_lifeOverTimer &&
                    m_playerControlled == false)
                {
                    break;
                }

                // If we are re-connected, do we need to login to our account?
                if (m_service.ConnectedToArbitrator == true && connectedLastFrame == false)
                {
                    LoginToAccount();
                    RegisterAsListening();
                }
                connectedLastFrame = m_service.ConnectedToArbitrator;

                // Simulate movement.
                SimulateMovement();

                // Update service.
                if (m_service.Poll())
                {
                    break;
                }

                Thread.Sleep(16);
            }

            // Abort the service.
            m_service.Deinitialize();
        }
 /// <summary>
 ///     Constructs a new instance of this class.
 /// </summary>
 /// <param name="service">Game client thats hosting this connection.</param>
 /// <param name="connection">Connection used to communicate with the super peer.</param>
 /// <param name="id">Client ID of superpeer on the other end of this connection.</param>
 public ClientToSuperPeerConnection(GameClientService service, Connection connection, int id)
 {
     m_service = service;
     m_connection = connection;
     m_clientID = id;
 }
 /// <summary>
 ///     Constructs a new instance of this class.
 /// </summary>
 /// <param name="gameClient">Game client hosting this connection.</param>
 /// <param name="service">Superpeer a client is connected to..</param>
 /// <param name="connection">Connection used to communicate with the super peer.</param>
 public SuperPeerToClientConnection(GameClientService gameClient, SuperPeer superpeer, Connection connection)
 {
     m_superpeer = superpeer;
     m_connection = connection;
     m_gameClient = gameClient;
 }
Пример #5
0
 /// <summary>
 ///     Constructs a new instance of this class.
 /// </summary>
 /// <param name="service">Game client thats running this superpeer.</param>
 /// <param name="superpeer_id">Internal numeric ID of this superpeer.</param>
 /// <param name="zone_id">Internal numeric ID of zone we have control of.</param>
 public SuperPeer(GameClientService service, int superpeer_id, int zone_id)
 {
     m_service = service;
     m_superpeer_id = superpeer_id;
     m_zone_id = zone_id;
 }