Exemplo n.º 1
0
    public void SerializeData(SendDataStruct data)
    {
        MemoryStream memStream = new MemoryStream();

        ProtoBuf.Serializer.Serialize(memStream, data.instance);

        byte[] body = memStream.ToArray();
        CMsg   _nnn = new CMsg();

        _nnn.dest = data.dest;
        _nnn.cmd  = data.cmd;
        if (body != null && body.Length > 0)
        {
            _nnn.body = body;
        }

        //放在消息队列里面发
        messageStruct smsg = new messageStruct();

        smsg.dest = data.dest;
        smsg.cmd  = data.cmd;
        smsg.body = PBParseManage.getSerialize <CMsg>(_nnn);

        NetWorkManage.getInstance().PushSendDataQueue(smsg);
    }
Exemplo n.º 2
0
    //发送协议数据到服务器 只传协议号,没有内容
    public static void SendData(int dest, int cmd)
    {
#if UNITY_EDITOR
        Debug.Log("要发送协议:dest=" + dest + ",cmd=" + cmd);
#endif
        SendPBMsg smsg = new SendPBMsg();
        smsg.dest = dest;
        smsg.cmd  = cmd;
        CMsg _nnn = new CMsg();
        _nnn.dest     = dest;
        _nnn.cmd      = cmd;
        smsg.sendBody = PBParseManage.getSerialize <CMsg>(_nnn);

        sendMemory.Add(smsg);
    }
Exemplo n.º 3
0
    //发送协议数据到服务器
    public static void SendData <T>(int dest, int cmd, T instance) where T : global::ProtoBuf.IExtensible
    {
#if UNITY_EDITOR
        Debug.Log("要发送协议:dest=" + dest + ",cmd=" + cmd);
#endif
        byte[] body = PBParseManage.getSerialize <T>(instance);
        CMsg   _nnn = new CMsg();
        _nnn.dest = dest;
        _nnn.cmd  = cmd;
        if (body != null && body.Length > 0)
        {
            _nnn.body = body;
        }

        //放在消息队列里面发
        SendPBMsg smsg = new SendPBMsg();
        smsg.dest     = dest;
        smsg.cmd      = cmd;
        smsg.sendBody = PBParseManage.getSerialize <CMsg>(_nnn);

        sendMemory.Add(smsg);
    }