Esempio n. 1
0
 public void OnReceive(int id, byte[] buf, int offset, int size)
 {
     if (UnreliableData.TryUnpack(buf, ref offset, out var data))
     {
         Get(id)?.Enqueue(data);
     }
 }
Esempio n. 2
0
        public static bool TryUnpack(byte[] buf, ref int offset, out UnreliableData data)
        {
            var channel  = BinaryUtil.ReadShort(buf, ref offset);
            var type     = buf[offset++];
            var sequence = BinaryUtil.ReadShort(buf, ref offset);
            var payload  = FragmentPool.Get();

            payload.Read(buf, ref offset);
            data = new UnreliableData(channel, sequence, payload);
            return(true);
        }
Esempio n. 3
0
 public void Send(List <Fragment> input)
 {
     foreach (var fragment in input)
     {
         using (var data = new UnreliableData(m_ChannelId, ++m_SendSequence, fragment))
         {
             data.Pack(m_Context.SharedSendBuffer, out var size);
             m_Context.Send(m_ConnectionId, m_Context.SharedSendBuffer, 0, size, m_Config.Encrypt);
         }
     }
 }