AccServer.SocketCallBack.Run C# (CSharp) Method

Run() public method

public Run ( ) : void
return void
        public void Run()
        {
            int runtime = System.Environment.TickCount;

            while (true)
            {
                if (System.Environment.TickCount - runtime > 300) break;//超出三百毫秒下次再处理
                SocketInfo info = GetInfo();
                if (info == null) break;
                if (info.s == null) break;
                Socket s = info.s;
                switch (info.type)
                {
                    case TYPE_ONCONNECT:
                        {

                            //  SessionManager.Instance().AddSession(s, GameServer.GetTcpServer());
                            break;
                        }
                    case TYPE_CLOSE:
                        {
                            // PlayerObject play = UserEngine.Instance().FindPlayerObjectToSocket(s);
                            //   SessionManager.Instance().RemoveSession(s);
                            //  UserEngine.Instance().RemovePlayObject(play);
                            //if (play != null)
                            // {
                            // play.GetGameSession().Dispose();
                            // play.SetGameSession(null);
                            //}

                            break;
                        }
                    case TYPE_RECEIVE:
                        {
                              GameBase.Network.GameSession session = info.session;
                             byte[] bydata = new byte[info.data.Length];
                             Buffer.BlockCopy(info.data, 0, bydata, 0, info.data.Length);
                             session.m_GamePack.ProcessNetData(bydata);
                            //            session.m_nLastTime = System.Environment.TickCount;

                             byte[] retdata = session.m_GamePack.GetData();
                            if (retdata != null)
                            {
                                GameBase.Network.PackIn packin = new GameBase.Network.PackIn(retdata);

                                ushort tag = packin.ReadUInt16();
                                switch (tag)
                                {

                                    case PacketProtoco.C_LOGINUSER:
                                        {

                                            GameBase.Network.PacketOut packout = new GameBase.Network.PacketOut(session.GetGamePackKeyEx());
                                            byte[] sendbyte = { 0, 1, 59, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                                      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 255, 255, 255, 255 };
                                            packout.WriteBuff(sendbyte);
                                            sendbyte = packout.Flush();
                                            Program.server.SendData(info.s, sendbyte);
                                            break;
                                        }

                                }
                            }
                            //  SessionManager.Instance().AddNetData(s, info.data, info.data.Length);
                            break;
                        }
                }

            }
        }