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); //} }
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); //} }
public static SocketCallBack Instance() { if (mInstance == null) { mInstance = new SocketCallBack(); } return(mInstance); }
public static SocketCallBack Instance() { if (mInstance == null) { mInstance = new SocketCallBack(); } return mInstance; }
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; // } // } // } // //空连接判断- // } //} }
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); //} }