CopyTo() public method

public CopyTo ( byte dest, int start ) : void
dest byte
start int
return void
Example #1
0
        //
        //
        //
        //
        public void WriteMessage(byte[] message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }
            m_WriteHeader.PayloadSize = message.Length;
            m_WriteHeader.CopyTo(m_WriteHeaderBuffer, 0);

            if (m_NetworkStream != null && message.Length != 0)
            {
                BufferOffsetSize[] buffers = new BufferOffsetSize[2];
                buffers[0] = new BufferOffsetSize(m_WriteHeaderBuffer, 0, m_WriteHeaderBuffer.Length, false);
                buffers[1] = new BufferOffsetSize(message, 0, message.Length, false);
                m_NetworkStream.MultipleWrite(buffers);
            }
            else
            {
                Transport.Write(m_WriteHeaderBuffer, 0, m_WriteHeaderBuffer.Length);
                if (message.Length == 0)
                {
                    return;
                }
                Transport.Write(message, 0, message.Length);
            }
        }
Example #2
0
        public void WriteMessage(byte[] message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            _writeHeader.PayloadSize = message.Length;
            _writeHeader.CopyTo(_writeHeaderBuffer, 0);

            Transport.Write(_writeHeaderBuffer, 0, _writeHeaderBuffer.Length);
            if (message.Length == 0)
            {
                return;
            }

            Transport.Write(message, 0, message.Length);
        }
Example #3
0
        public async Task WriteMessageAsync <TAdapter>(Stream stream, byte[] message, CancellationToken cancellationToken)
            where TAdapter : IReadWriteAdapter
        {
            _writeHeader.PayloadSize = message.Length;
            _writeHeader.CopyTo(_writeHeaderBuffer, 0);

            await TAdapter.WriteAsync(stream, _writeHeaderBuffer, 0, _writeHeaderBuffer.Length, cancellationToken).ConfigureAwait(false);

            if (message.Length != 0)
            {
                await TAdapter.WriteAsync(stream, message, 0, message.Length, cancellationToken).ConfigureAwait(false);
            }
        }
Example #4
0
        public async Task WriteMessageAsync <TAdapter>(TAdapter adapter, byte[] message) where TAdapter : IReadWriteAdapter
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            _writeHeader.PayloadSize = message.Length;
            _writeHeader.CopyTo(_writeHeaderBuffer, 0);

            await adapter.WriteAsync(_writeHeaderBuffer, 0, _writeHeaderBuffer.Length).ConfigureAwait(false);

            if (message.Length != 0)
            {
                await adapter.WriteAsync(message, 0, message.Length).ConfigureAwait(false);
            }
        }