Exemplo n.º 1
0
        public override byte[] PrepareToSend(byte[] data)
        {
            data = InternalChannel.PrepareToSend(data);
            var header   = BitConverter.GetBytes((ushort)data.Length);
            var fullData = new byte[header.Length + data.Length];

            Array.Copy(header, 0, fullData, 0, header.Length);
            Array.Copy(data, 0, fullData, header.Length, data.Length);
            //UnityEngine.Debug.LogError("Prepare: " + GetType().ToString() + ": " + DeBox.Teleport.Debugging.TeleportDebugUtils.DebugString(fullData));
            return(fullData);
        }
        public override byte[] PrepareToSend(byte[] data)
        {
            data = InternalChannel.PrepareToSend(data);
            byte[] sequenceBytes = BitConverter.GetBytes(_outgoingSequence);
            var    newData       = new byte[data.Length + sequenceBytes.Length];

            Array.Copy(sequenceBytes, 0, newData, 0, sequenceBytes.Length);
            Array.Copy(data, 0, newData, sequenceBytes.Length, data.Length);
            if (_sendAcks)
            {
                lock (_outboxLock)
                {
                    _outbox[_outgoingSequence] = new OutboxItem()
                    {
                        data = newData, nextSendTime = DateTime.UtcNow.Ticks + ACK_TIMEOUT_DURATION_IN_TICKS
                    };
                }
            }
            _outgoingSequence++;
            return(newData);
        }
Exemplo n.º 3
0
        public override byte[] PrepareToSend(byte[] data)
        {
            data = InternalChannel.PrepareToSend(data);
            byte[] sequenceBytes = BitConverter.GetBytes(_outgoingSequence);
            var    newData       = new byte[data.Length + sequenceBytes.Length];

            Array.Copy(sequenceBytes, 0, newData, 0, sequenceBytes.Length);
            Array.Copy(data, 0, newData, sequenceBytes.Length, data.Length);
            if (_sendAcks)
            {
                lock (_outboxLock)
                {
                    _outbox[_outgoingSequence] = new OutboxItem()
                    {
                        data = newData, lastSendTime = DateTime.UtcNow.Ticks
                    };
                }
            }
            _outgoingSequence++;
            //UnityEngine.Debug.LogError("Prepare: " + GetType().ToString() + ": " + DeBox.Teleport.Debugging.TeleportDebugUtils.DebugString(newData));
            return(newData);
        }