Example #1
0
        /// <summary>
        /// This method initializes a ping checker for the given connection
        /// </summary>
        /// <param name="handeler">The connection to poll</param>
        public PingChecker(ConnectionHandeler handeler)
        {
            this.handeler = handeler;
            pingResponseTime = new Stopwatch();

            int pingInterval = AwsomeLicense.Configuration.getInt("ping.interval");

            handeler.Disconnection += userDisconnected;
            if (pingInterval <= 1)
                pingInterval = 1;
            pingInterval *= 1000;
            myPingTimer = new Timer(pingInterval);
            handeler.addPacketHandeler(ServerOpCode.Ping_Response, handleReceivedPing);
            myPingTimer.Elapsed += new ElapsedEventHandler(doPingCheck);
            myPingTimer.Start();
        }
Example #2
0
        /// <summary>
        /// Called when the user disconnects
        /// </summary>
        private void userDisconnected(ConnectionHandeler handeler)
        {
            myPingTimer.Elapsed -= doPingCheck;
            handeler.Disconnection += userDisconnected;

            handeler.removeHandeler(ServerOpCode.Ping_Response);
            myPingTimer.Dispose();
        }