예제 #1
0
    public byte[] toBytes()
    {
        byte[] data   = new byte[mHeaderLength];
        int    offset = 0;

        BinaryUtility.writeByte(data, ref offset, mReportID);
        BinaryUtility.writeByte(data, ref offset, mMagicByte);
        BinaryUtility.writeByte(data, ref offset, mVersion);
        BinaryUtility.writeShort(data, ref offset, (short)mPayloadLength, true);
        BinaryUtility.writeShort(data, ref offset, (short)mCRC16, true);
        BinaryUtility.writeShort(data, ref offset, (short)mSeqID, true);
        return(data);
    }
예제 #2
0
    public override byte[] toBytes()
    {
        mCmdID       = 2;
        mKeyID       = 1;
        mValueLength = sizeof(byte);
        int payloadLen = sizeof(byte) + sizeof(byte) + sizeof(byte) + mValueLength;

        byte[] payload = new byte[payloadLen];
        int    index   = 0;

        BinaryUtility.writeByte(payload, ref index, mCmdID);
        BinaryUtility.writeByte(payload, ref index, mKeyID);
        BinaryUtility.writeByte(payload, ref index, mValueLength);
        BinaryUtility.writeByte(payload, ref index, mFriction);
        mHeader = new PacketHeader(GameDefine.REPORT_OUT);
        mHeader.mPayloadLength = (ushort)payloadLen;
        mHeader.mCRC16         = BinaryUtility.crc16(0xFF, payload, payloadLen);
        byte[] headerData = mHeader.toBytes();
        byte[] packetData = new byte[payload.Length + headerData.Length];
        BinaryUtility.memcpy(packetData, headerData, 0);
        BinaryUtility.memcpy(packetData, payload, headerData.Length);
        return(packetData);
    }
예제 #3
0
 public override void writeToBuffer(byte[] buffer, ref int index)
 {
     BinaryUtility.writeByte(buffer, ref index, mValue);
 }