示例#1
0
        /// <summary>
        /// Initializes 'cache to login' connection.
        /// </summary>
        /// <param name="remoteEP">Remote cache service endpoint.</param>
        /// <param name="reconnectAttemptInterval">Interval between reconnection attempts.</param>
        internal static void Initialize(IPEndPoint remoteEP, TimeSpan reconnectAttemptInterval)
        {
            if (Connection != null && Connection.Connected)
            {
                Logger.WriteLine(Source.InnerNetwork, "Already connected to remote cache service.");
                return;
            }

            if (Connection == null)
            {
                Connection = new InnerNetworkConnection(remoteEP, reconnectAttemptInterval);
                Connection.HandleDelegate  = CacheServiceRequestsHandlers.Handle;
                Connection.OnConnected    += new OnConnectedEventHandler(Connection_OnConnected);
                Connection.OnDisconnected += new OnDisconnectedEventHandler(Connection_OnDisconnected);
            }
            else
            {
                Connection.RemoteEndPoint    = remoteEP;
                Connection.ReconnectInterval = reconnectAttemptInterval;
            }

            Logger.WriteLine(Source.InnerNetwork, "Initializing cache service connection.");

            Connection.BeginConnect();
        }
 /// <summary>
 /// Initializes new instance of <see cref="GameServiceRequestsHandlers"/> class.
 /// </summary>
 /// <param name="connection">Referenced <see cref="InnerNetworkConnection"/> object.</param>
 /// <param name="connectionID">Connection id.</param>
 internal GameServiceRequestsHandlers(ref InnerNetworkConnection connection, byte connectionID)
 {
     Connection   = connection;
     ConnectionID = connectionID;
 }