Exemplo n.º 1
0
    public P2PMsg4Send(byte id, ushort meta, byte src, byte dst, P2PMsgBody msgBody, byte sendKey)
    {
        ushort num = (ushort)msgBody.Offset;
        byte   b   = 0;

        if (sendKey == 255)
        {
            for (int i = 0; i < num; i++)
            {
                b = (byte)(b ^ msgBody.Buffer[i]);
            }
        }
        else
        {
            for (int j = 0; j < num; j++)
            {
                b = (byte)(b ^ msgBody.Buffer[j]);
                msgBody.Buffer[j] ^= sendKey;
            }
        }
        _meta   = meta;
        _io     = 0;
        _buffer = new byte[8 + num];
        P2PMsgHdr p2PMsgHdr = new P2PMsgHdr(num, id, b, meta, src, dst);

        byte[] array = p2PMsgHdr.ToArray();
        Array.Copy(array, _buffer, array.Length);
        Array.Copy(msgBody.Buffer, 0, _buffer, array.Length, num);
    }
Exemplo n.º 2
0
    public byte[] GetFullPacketBuffer(byte id)
    {
        ushort num = (ushort)_offset;
        byte   b   = 0;

        for (int i = 0; i < num; i++)
        {
            b = (byte)(b ^ _buffer[i]);
        }
        byte[]    array     = new byte[8 + num];
        P2PMsgHdr p2PMsgHdr = new P2PMsgHdr(num, id, b, ushort.MaxValue, byte.MaxValue, byte.MaxValue);

        byte[] array2 = p2PMsgHdr.ToArray();
        Array.Copy(array2, array, array2.Length);
        Array.Copy(_buffer, 0, array, array2.Length, num);
        return(array);
    }