Пример #1
0
        public static void Process()
        {
            if (!Connected)
            {
                if (TimeConnected == 0 && Main.Time >= 10000)
                {
                    MirScenes.SceneFunctions.ConnectionClosed();
                }
                return;
            }

            while (ReceiveList.Count > 0)
            {
                InBound.ProcessPacket(ReceiveList.Dequeue());
            }

            if (Main.Time > TimeOutTime)
            {
                OutBound.KeepAlive();
            }

            while (SendList.Count > 0)
            {
                TimeOutTime = Main.Time + Settings.TimeOut;
                BeginSend(SendList.Dequeue());
            }
        }
Пример #2
0
        public static void Disconnect()
        {
            while (Connected && SendList.Count > 0)
            {
                BeginSend(SendList.Dequeue());
            }

            Connected = false;

            if (Client != null)
            {
                Client.Client.Dispose();
            }
            Client = null;
            SendList.Clear();
            ReceiveList.Clear();
        }
Пример #3
0
        public void Process()
        {
            while (ReceiveList.Count > 0)
            {
                ProcessPacket(ReceiveList.Dequeue());
                TimeOutTime = Main.Time + Settings.TimeOut;
            }

            if (Main.Time > TimeOutTime)
            {
                Connected = false;
                SendList.Clear();
                Disconnect();
                return;
            }

            while (SendList.Count > 0)
            {
                BeginSend(SendList.Dequeue());
            }
        }
Пример #4
0
        public void Disconnect()
        {
            while (Connected && SendList.Count > 0)
            {
                BeginSend(SendList.Dequeue());
            }

            Connected = false;

            if (Stage == GameStage.Disconnected)
            {
                return;
            }

            if (Stage == GameStage.Game)
            {
                Player.DeSpawn();
            }

            Stage = GameStage.Disconnected;

            TimeDisconnected = Main.Time;

            if (TClient != null)
            {
                TClient.Client.Dispose();
            }
            TClient = null;

            Account = null;
            SendList.Clear();
            ReceiveList.Clear();

            Network.ActiveConnections.Remove(this);
            if (!Network.ExpiredConnections.Contains(this))
            {
                Network.ExpiredConnections.Add(this);
            }
        }