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);
    }
Esempio n. 2
0
 public P2PMsg2Handle(ushort id, P2PMsgBody msg, IPEndPoint recvFrom, ushort meta, byte src, byte dst)
 {
     _id       = id;
     _msg      = msg;
     _recvFrom = recvFrom;
     _meta     = meta;
     _src      = src;
     _dst      = dst;
 }
    public P2PMsgBody Flush()
    {
        P2PMsgBody result = new P2PMsgBody(_buffer, 8, _hdr._size);

        _io -= 8 + _hdr._size;
        if (_io > 0)
        {
            Array.Copy(_buffer, 8 + _hdr._size, _buffer, 0, _io);
        }
        return(result);
    }
Esempio n. 4
0
 private void hP2PManagerReliableSend(uint to, byte id, P2PMsgBody mb)
 {
     P2PManager.Instance.Say(id, mb);
 }