Exemplo n.º 1
0
    void Start()
    {
        buf     = new byte[50];
        msg     = new MsgHead();
        m_opNew = GameManager.Instance.mainPlayer.m_protoInfo.Op;
        m_opOld = new Operation();

        msg.setId(GameManager.Instance.mainPlayer.m_protoInfo.Id);
        msg.setType(EventType.UPDATE);
        m_opNew.H = 0;
        m_opNew.V = 0;
        m_opOld.H = 0;
        m_opOld.V = 0;
    }
Exemplo n.º 2
0
    public int SendMessage <T>(T _protobuffer, EventType mode) where T : global::Google.Protobuf.IMessage <T>, new()
    {
        Debug.Log("sendmessage type " + mode);

        m_msgHeadSend.setType(mode);

        byte[] tmp = Google.Protobuf.MessageExtensions.ToByteArray(_protobuffer);

        m_msgHeadSend.m_len = (UInt32)tmp.Length;

        Debug.Log("protobuf size is " + _protobuffer.CalculateSize());

        Debug.Log("head.type is" + m_msgHeadSend.m_type + "head.id is" + m_msgHeadSend.m_usrid + "protobuf size is " + m_msgHeadSend.m_len);

        m_msgHeadSend.EnCode(m_sendbuf, 0);

        tmp.CopyTo(m_sendbuf, MsgHead.headsize());
        if (Send(m_sendbuf, m_msgHeadSend.m_len + MsgHead.headsize()) < 0)
        {
            return(-1);
        }

        return(0);
    }