コード例 #1
0
        private static void ExecuteLatencyMonitor(object state)
        {
            ServerMessage PingMessage = PingComposer.Compose();

            lock (mSessions)
            {
                lock (mSessionsToStop)
                {
                    foreach (Session Session in mSessions.Values)
                    {
                        if (Session.Stopped || mSessionsToStop.Contains(Session.Id))
                        {
                            continue;
                        }

                        if (!Session.LatencyTestOk)
                        {
                            mSessionsToStop.Add(Session.Id);
                            continue;
                        }

                        Session.LatencyTestOk = false;
                        Session.SendData(PingMessage);
                    }
                }
            }
        }
コード例 #2
0
        private static void ExecuteLatencyMonitor()
        {
            try
            {
                while (Program.Alive)
                {
                    ServerMessage PingMessage = PingComposer.Compose();

                    lock (mSessions)
                    {
                        lock (mSessionsToStop)
                        {
                            foreach (Session Session in mSessions.Values)
                            {
                                if (Session.Stopped || mSessionsToStop.Contains(Session.Id))
                                {
                                    continue;
                                }

                                if (!Session.LatencyTestOk)
                                {
                                    mSessionsToStop.Add(Session.Id);
                                    continue;
                                }

                                Session.LatencyTestOk = false;
                                Session.SendData(PingMessage);
                            }
                        }
                    }

                    Thread.Sleep(45000);
                }
            }
            catch (ThreadAbortException) { }
            catch (ThreadInterruptedException) { }
        }
コード例 #3
0
        private void method_3(byte[] byte_1)
        {
            if ((byte_1[0] == 60) && (byte_1[1] == 0x70))
            {
                this.SendData(CrossdomainPolicy.GetBytes(), true);
                SessionManager.StopSession(this.uint_0);
            }
            else if (byte_1[0] == 0xb1)
            {
                string[] strArray = Constants.DefaultEncoding.GetString(byte_1).Split(new char[] { '\x00b0' });
                try
                {
                    byte[] bytes;
                    foreach (string str in strArray)
                    {
                        bytes = Constants.DefaultEncoding.GetBytes(str + 1);
                        if (bytes.Length > 3)
                        {
                            bytes[bytes.Length - 1] = 0xb0;
                            if (bytes[3] == 0xb2)
                            {
                                if (bytes[1] == 0xa3)
                                {
                                    this.SendData(PingComposer.Compose(), false);
                                    if (bytes.Length <= 5)
                                    {
                                        continue;
                                    }
                                    goto Label_0238;
                                }
                                int num = 4;
                                while (num < bytes.Length)
                                {
                                    ClientMessage message = null;
                                    try
                                    {
                                        ushort messageFlag = bytes[1];
                                        byte[] body        = new byte[bytes.Length - 4];
                                        for (int i = 0; i < body.Length; i++)
                                        {
                                            body[i] = bytes[num++];
                                        }
                                        message = new ClientMessage(messageFlag, 0, body);
                                    }
                                    catch (Exception)
                                    {
                                        Output.WriteLine("Packet formatting exception on packet: " + Constants.DefaultEncoding.GetString(bytes), OutputLevel.DebugNotification);
                                        break;
                                    }
                                    if (message != null)
                                    {
                                        try
                                        {
                                            DataRouter.HandleData(this, message);
                                            continue;
                                        }
                                        catch (Exception exception)
                                        {
                                            Output.WriteLine("Critical error in HandleData stack: " + exception.Message + "\n\n" + exception.StackTrace, OutputLevel.CriticalError);
                                            break;
                                        }
                                    }
                                }
                                continue;
                            }
                            int num4 = 6;
                            while (num4 < bytes.Length)
                            {
                                ClientMessage message2 = null;
                                try
                                {
                                    ushort num5        = bytes[1];
                                    ushort messageItem = bytes[3];
                                    byte[] buffer3     = new byte[bytes.Length - 6];
                                    for (int j = 0; j < buffer3.Length; j++)
                                    {
                                        buffer3[j] = bytes[num4++];
                                    }
                                    message2 = new ClientMessage(num5, messageItem, buffer3);
                                }
                                catch (Exception)
                                {
                                    Output.WriteLine("Packet formatting exception on packet: " + Constants.DefaultEncoding.GetString(bytes), OutputLevel.DebugNotification);
                                    break;
                                }
                                if (message2 != null)
                                {
                                    try
                                    {
                                        DataRouter.HandleData(this, message2);
                                        continue;
                                    }
                                    catch (Exception exception2)
                                    {
                                        Output.WriteLine("Critical error in HandleData stack: " + exception2.Message + "\n\n" + exception2.StackTrace, OutputLevel.CriticalError);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    return;

Label_0238:
                    if (bytes[5] == 120)
                    {
                        this.SendData(FacebookInitComposer.Compose(), false);
                    }
                }
                catch (Exception exception3)
                {
                    Console.WriteLine(exception3.ToString());
                }
            }
            else
            {
                SessionManager.StopSession(this.uint_0);
            }
        }
コード例 #4
0
 private static void Ping(Session Session, ClientMessage Message)
 {
     Session.SendData(PingComposer.Compose());
 }