Ejemplo n.º 1
0
 public static KCPPacketHandlerMgr GetInstance()
 {
     if (KCPPacketHandlerMgr.s_KCPPacketHandlerMgr == null)
     {
         KCPPacketHandlerMgr.s_KCPPacketHandlerMgr = new KCPPacketHandlerMgr();
     }
     return(KCPPacketHandlerMgr.s_KCPPacketHandlerMgr);
 }
Ejemplo n.º 2
0
    static void server_RecvData(ClientSession session, byte[] data, int offset, int size)
    {
        //byte cmd = data[offset];
        //offset++;
        //收到马上转发
        //string s = System.Text.Encoding.UTF8.GetString(data, offset + 4, size - 4);
        //Console.WriteLine("Recv From:" + session.NetIndex.ToString() + " " + session.EndPoint.ToString() + " data:" + s);
        //session.Send(s);
        UnityEngine.Debug.Log("server_RecvData");
        //读4个字节的Key校验
        uint key    = BitConverter.ToUInt32(data, offset);
        int  length = data.Length - offset - 4;

        byte[] msg = new byte[length];
        Array.Copy(data, offset + 4, msg, 0, length);
        WfPacket item = new WfPacket(msg);

        //向逻辑层抛
        KCPPacketHandlerMgr.GetInstance().ProcessPacket(session, item);
    }
Ejemplo n.º 3
0
 public static void Init()
 {
     //初始化消息注册
     KCPPacketHandlerMgr.GetInstance().Register(0, OnClientMsg);
 }