Esempio n. 1
0
        public PackageIn msg;      // 数据buff

        public NetCommand()
        {
            this.dwType = NetCmdType.NetCmd_Null;
            this.dwLen  = 0;
            this.error  = NetWorkError.NetWorkError_null;
            msg         = null;
        }
Esempio n. 2
0
    public static ViewPlayerData BuildViewData(GameCmd.stViewRoleReturnPropertyUserCmd_S cmd)
    {
        retData            = new ViewPlayerData();
        retData.userid     = cmd.userid;
        retData.user_level = cmd.user_level;
        retData.userid     = cmd.userid;
        retData.username   = cmd.username;
        retData.sex        = cmd.sex;
        retData.power      = cmd.power;
        retData.job        = cmd.job;
        retData.clan_name  = cmd.clan_name;

        retData.gem_data     = cmd.gem_data;
        retData.viewRoleData = cmd.user_data;
        retData.suit_data    = cmd.suit_data;
        retData.itemList     = cmd.itemList;
        retData.strengthList = cmd.strength_data;

        Engine.PackageIn pack = new Engine.PackageIn(cmd.pet_data);
        retData.petdata = GameCmd.PetUserData.Deserialize(pack);

        pack             = new Engine.PackageIn(cmd.ride_data);
        retData.rideData = GameCmd.RideUserData.Deserialize(pack);

        return(retData);
    }
Esempio n. 3
0
 // 网络包解析 在网络接收线程中调用,注意API的使用
 public void ParsePackage(byte[] buff, out List <PackageIn> lstPackage)
 {
     lstPackage = m_lstPackageIn;
     Engine.PackageIn          msg     = new Engine.PackageIn(buff);
     Pmd.ForwardNullUserPmd_CS package = Pmd.ForwardNullUserPmd_CS.Deserialize(msg);
     ParsePackage(package, buff.Length);
     msg.Close();
 }
Esempio n. 4
0
 public NetCommand(NetCommand cmd)
 {
     this.dwType = cmd.dwType;
     this.dwLen  = cmd.dwLen;
     if (this.dwLen > 0)
     {
         this.msg = cmd.msg;
     }
 }
Esempio n. 5
0
        public void PushRecv(PackageIn msg)
        {
            NetCommand cmd = new NetCommand();

            cmd.dwType = NetCmdType.NetCmd_Recv;
            cmd.msg    = msg;
            cmd.dwLen  = (int)msg.Length;
            //cmd.buff.Write(buff, 0,nLen);
            m_NetCommandList.Push(cmd);
        }
Esempio n. 6
0
        public void OnRecv(PackageIn msg)
        {
            if (m_NetLinkSink != null)
            {
                m_NetLinkSink.OnReceive(msg);
            }

            if (m_NetLinkMonitor != null)
            {
                m_NetLinkMonitor.OnReceive(msg);
            }
        }
Esempio n. 7
0
    // 包解析
    private void ParsePackage(Pmd.ForwardNullUserPmd_CS package, int buffLen = 0)
    {
        if (package == null)
        {
            return;
        }

        // 消息解压
        if ((package.bitmask & (uint)Pmd.FrameHeader.Bitmask_Compress) != 0)
        {
            package.bitmask &= ~(uint)Pmd.FrameHeader.Bitmask_Compress; // 去掉压缩标记
            package.data     = Common.ZlibCodec.Decode(package.data);
        }

        // 嵌套打包
        if ((package.bitmask & (uint)Pmd.FrameHeader.Bitmask_Header) != 0)
        {
            package.bitmask &= ~(uint)Pmd.FrameHeader.Bitmask_Header; // 去掉嵌套打包标记

            using (var mem = new MemoryStream(package.data))
            {
                while (mem.Position < mem.Length)
                {
                    var embed = Pmd.ForwardNullUserPmd_CS.DeserializeLengthDelimited(mem);
                    ParsePackage(embed);
                }
                if (mem.Position >= mem.Length)
                {
                    return;
                }
            }
        }

        Engine.PackageIn pack = PackageInPool.Alloc();
        pack.buffLen = buffLen;
        try
        {
            package.SerializeLengthDelimited(pack);
        }
        catch (System.Exception ex)
        {
            //Engine.Utility.Log.Error("");
            //string str = ex.ToString();
        }

        m_lstPackageIn.Add(pack);
    }
Esempio n. 8
0
    public void OnReceive(Engine.PackageIn msg)
    {
        if (m_receiveMsgCallback != null)
        {
#if PROFILER
            UnityEngine.Profiling.Profiler.BeginSample("--------------NetService->OnReceive");
#endif
            byte[] msgArray = PraseMsg(msg.ToArray());

            string strMsg = System.Text.Encoding.Default.GetString(msgArray);

            m_receiveMsgCallback(CallbackOwner, strMsg);
#if PROFILER
            UnityEngine.Profiling.Profiler.EndSample();
#endif
        }
        else
        {
            Utility.Log.Error("OnReceive callback null");
        }
    }
Esempio n. 9
0
 public void OnReceive(Engine.PackageIn msg)
 {
     Pmd.ForwardNullUserPmd_CS package = Pmd.ForwardNullUserPmd_CS.DeserializeLengthDelimited(msg);
     OnPackage(package);
     DispatchMessage();
 }