Ejemplo n.º 1
0
        /// <summary>
        ///     Sets up the connection to an arbitrator to recieve information about the game world.
        /// </summary>
        /// <returns>Returns true if successful, else false.</returns>
        private async Task<bool> SetupArbitratorConnection()
        {
            bool result = false;

            if (m_arbitratorConnection == null)
            {
                Logger.Info("Attempting to connect to arbitrator on {0}:{1} ...", LoggerVerboseLevel.High, m_arbitratorHost, m_arbitratorPort);

                m_arbitratorConnection = new Connection();
                result = await m_arbitratorConnection.ConnectAsync(m_arbitratorHost, m_arbitratorPort);
            }
            else
            {
                Logger.Error("Lost connection to arbitrator, attempting to setup connection again ...", LoggerVerboseLevel.Normal);
                result = await m_arbitratorConnection.ReconnectAsync();
            }

            if (result == false)
            {
                Logger.Error("Failed to connect to arbitrator on {0}:{1}", LoggerVerboseLevel.Normal, m_arbitratorHost, m_arbitratorPort);
            }
            else
            {
                Logger.Info("Successfully connected to arbitrator.", LoggerVerboseLevel.High);
            }

            return result;
        }