예제 #1
0
 public P2PMsg4Recv(byte[] src)
 {
     _io     = 0;
     _hdr    = new P2PMsgHdr();
     _buffer = new byte[src.Length];
     Array.Copy(src, _buffer, src.Length);
 }
예제 #2
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);
    }
예제 #3
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);
    }
예제 #4
0
 public P2PMsg4Recv()
 {
     _io     = 0;
     _hdr    = new P2PMsgHdr();
     _buffer = new byte[4096];
 }