Example #1
0
    //解析协议信息
    private void ParseData(Stream source)
    {
        CMsg cmsg       = ProtoBuf.Serializer.Deserialize <CMsg>(source);
        int  cmd        = cmsg.cmd;
        int  dest       = cmsg.dest;
        long serverTime = cmsg.serverTime;

        byte[] body = cmsg.body;
        //消息号保存进队列
        PBNO _pb = new PBNO();

        _pb.msg        = cmsg;
        _pb.pbInstance = null;

        //分发协议去解析
        _pb.pbInstance = PBParseManage.getInstance().ParseData(dest, cmd, body);

        if (IsOftenData(dest, cmd))
        {
            recDataScene.Enqueue(_pb);
        }
        else
        {
            recDataQueue.Enqueue(_pb);
        }

        Debug.Log("收到消息 dest=" + dest + ",cmd=" + cmd);
    }
Example #2
0
    public object DeserializeData(object source)
    {
        Debug.Log("DeserializeData");

        if (source == null)
        {
            return(null);
        }

        Stream stream = (Stream)source;

        CMsg cmsg       = ProtoBuf.Serializer.Deserialize <CMsg>(stream);
        int  cmd        = cmsg.cmd;
        int  dest       = cmsg.dest;
        long serverTime = cmsg.serverTime;

        byte[] body = cmsg.body;


        //消息号保存进队列
        PBNO _pb = new PBNO();

        _pb.msg = cmsg;

        //分发协议去解析
        PBParseManage.getInstance().ParseData(dest, cmd, body);

        if (NetWorkManage.getInstance().IsOftenData(dest, cmd))
        {
            NetWorkManage.getInstance().PushReceDataScene(_pb);
        }
        else
        {
            NetWorkManage.getInstance().PushReceDataQueue(_pb);
        }

        Debug.Log("收到消息 dest=" + dest + ",cmd=" + cmd);

        return(null);
    }
Example #3
0
    public void DeserializeData(ReceDataStruct source)
    {
        if (source == null)
        {
            return;
        }

        Stream stream = new MemoryStream(source.data, 0, source.datalen);

        CMsg cmsg       = ProtoBuf.Serializer.Deserialize <CMsg>(stream);
        int  cmd        = cmsg.cmd;
        int  dest       = cmsg.dest;
        long serverTime = cmsg.serverTime;

        byte[] body = cmsg.body;

        //消息号保存进队列
        messageStruct _pb = new messageStruct();

        _pb.cmd        = cmsg.cmd;
        _pb.dest       = cmsg.cmd;
        _pb.body       = cmsg.body;
        _pb.serverTime = cmsg.serverTime;

        //分发协议去解析
        PBParseManage.getInstance().ParseData(dest, cmd, body);

        if (NetWorkManage.getInstance().IsOftenData(dest, cmd))
        {
            NetWorkManage.getInstance().PushReceDataScene(_pb);
        }
        else
        {
            NetWorkManage.getInstance().PushReceDataQueue(_pb);
        }

        Debug.Log("收到消息 dest=" + dest + ",cmd=" + cmd);
    }