예제 #1
0
파일: Program.cs 프로젝트: tangfengray/soul
        public static void OnClose(Socket s)
        {
            SocketInfo info = new SocketInfo();

            info.type = SocketCallBack.TYPE_CLOSE;
            info.s    = s;
            SocketCallBack.Instance().AddData(info);
            //try
            //{
            //    lock (m_DicSession)
            //    {
            //        if (m_DicSession.ContainsKey(s))
            //        {
            //            GameBase.Network.GameSession session = m_DicSession[s];
            //            m_DicSession.Remove(s);
            //            session = null;
            //        }
            //    }
            //}
            //catch (System.Exception ex)
            //{
            //    Log.Instance().WriteLog(ex.Message);
            //    Log.Instance().WriteLog(ex.StackTrace);
            //}
        }
예제 #2
0
파일: Program.cs 프로젝트: tangfengray/soul
        public static void OnRecv(Socket s, byte[] data, int nSize)
        {
            SocketInfo info = new SocketInfo();

            info.type = SocketCallBack.TYPE_RECEIVE;
            info.s    = s;
            info.data = new byte[nSize];
            Buffer.BlockCopy(data, 0, info.data, 0, nSize);
            SocketCallBack.Instance().AddData(info);
            //try
            //{
            //    lock (m_DicSession)
            //    {
            //        if (m_DicSession.ContainsKey(s))
            //        {
            //            GameBase.Network.GameSession session = m_DicSession[s];
            //            byte[] bydata = new byte[nSize];
            //            Buffer.BlockCopy(data, 0, bydata, 0, nSize);
            //            session.m_GamePack.ProcessNetData(bydata);
            //            session.m_nLastTime = System.Environment.TickCount;
            //        }
            //    }
            //}
            //catch (System.Exception ex)
            //{
            //    Log.Instance().WriteLog(ex.Message);
            //    Log.Instance().WriteLog(ex.StackTrace);
            //}
        }
예제 #3
0
 public static SocketCallBack Instance()
 {
     if (mInstance == null)
     {
         mInstance = new SocketCallBack();
     }
     return(mInstance);
 }
예제 #4
0
 public static SocketCallBack Instance()
 {
     if (mInstance == null)
     {
         mInstance = new SocketCallBack();
     }
     return mInstance;
 }
예제 #5
0
파일: Program.cs 프로젝트: tangfengray/soul
        public static void LogicTimer(object source, ElapsedEventArgs e)
        {
            SocketCallBack.Instance().Run();
            //lock (m_DicSession)
            //{
            //    foreach (GameBase.Network.GameSession session in m_DicSession.Values)
            //    {
            //        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();
            //                        server.SendData(session.m_Socket, sendbyte);
            //                        break;
            //                    }

            //            }
            //        }

            //        //空连接判断-

            //    }
            //}
        }
예제 #6
0
파일: Program.cs 프로젝트: tangfengray/soul
        public static void OnConnect(Socket s)
        {
            SocketInfo info = new SocketInfo();

            info.type = SocketCallBack.TYPE_ONCONNECT;
            info.s    = s;
            SocketCallBack.Instance().AddData(info);
            //try
            //{
            //    lock (m_DicSession)
            //    {
            //        GameBase.Network.GameSession session = new GameBase.Network.GameSession(s);
            //        m_DicSession[s] = session;
            //    }
            //}
            //catch (System.Exception ex)
            //{
            //    Log.Instance().WriteLog(ex.Message);
            //    Log.Instance().WriteLog(ex.StackTrace);
            //}
        }