示例#1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="StringResources">The StringResources to use.</param>
        public ServerConnection(LockingDictionary <uint, string> StringResources)
        {
            // init the queues (receive, send, logs, exceptions)
            ReceiveQueue   = new LockingQueue <GameMessage>();
            SendQueue      = new LockingQueue <GameMessage>();
            ExceptionQueue = new LockingQueue <Exception>();

            // the debugqueue to give back sent packets (with crc/...) if activated
            OutgoingPacketLog = new LockingQueue <GameMessage>();

            // save reference to string dictionary
            stringResources = StringResources;

            // setup the packetcontroller
            messageController = new MessageControllerClient(StringResources);

            // hook up listeners
            messageController.MessageAvailable    += new GameMessageEventHandler(OnMessageControllerNewMessageAvailable);
            messageController.ServerSaveChanged   += new ServerSaveChangedEventHandler(OnMessageControllerNewServerSave);
            messageController.HandlerError        += new HandlerErrorEventHandler(OnMessageControllerHandlerError);
            messageController.ProtocolModeChanged += new EventHandler(OnMessageControllerProtocolModeChanged);

            // setup the ping timer
            timPing          = new System.Timers.Timer();
            timPing.Enabled  = false;
            timPing.Interval = PINGINTERVAL;
            timPing.Elapsed += new ElapsedEventHandler(OnPingTimerElapsed);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="StringResources">The StringResources to use.</param>
        public ServerConnection(LockingDictionary<uint, string> StringResources)
        {
            // init the queues (receive, send, logs, exceptions)
            ReceiveQueue = new LockingQueue<GameMessage>();
            SendQueue = new LockingQueue<GameMessage>();
            ExceptionQueue = new LockingQueue<Exception>();

            // the debugqueue to give back sent packets (with crc/...) if activated
            OutgoingPacketLog = new LockingQueue<GameMessage>();

            // save reference to string dictionary
            stringResources = StringResources;

            // setup the packetcontroller
            messageController = new MessageControllerClient(StringResources);

            // hook up listeners
            messageController.MessageAvailable += new GameMessageEventHandler(OnMessageControllerNewMessageAvailable);
            messageController.ServerSaveChanged += new ServerSaveChangedEventHandler(OnMessageControllerNewServerSave);
            messageController.HandlerError += new HandlerErrorEventHandler(OnMessageControllerHandlerError);
            messageController.ProtocolModeChanged += new EventHandler(OnMessageControllerProtocolModeChanged);

            // setup the ping timer
            timPing = new System.Timers.Timer();
            timPing.Enabled = false;
            timPing.Interval = PINGINTERVAL;
            timPing.Elapsed += new ElapsedEventHandler(OnPingTimerElapsed);
        }