Encode() public method

public Encode ( ) : byte[]
return byte[]
Ejemplo n.º 1
0
        public async Task Send(byte[] packet)
        {
            if (!_tcpClient.Connected)
                throw new InvalidOperationException("Client not connected to server.");

            var tcpMessage = new TcpMessage(sendCounter, packet);

            await _tcpClient.GetStream().WriteAsync(tcpMessage.Encode(), 0, tcpMessage.Encode().Length);
            sendCounter++;
        }
Ejemplo n.º 2
0
        public async Task Send(byte[] packet)
        {
            if (!_tcpClient.Connected)
            {
                throw new InvalidOperationException("Client not connected to server.");
            }

            var tcpMessage = new TcpMessage(sendCounter, packet);

            await _tcpClient.GetStream().WriteAsync(tcpMessage.Encode(), 0, tcpMessage.Encode().Length);

            sendCounter++;
        }
Ejemplo n.º 3
0
        public async Task Send(byte[] packet, CancellationToken token = default(CancellationToken))
        {
            if (!_tcpClient.Connected)
            {
                throw new InvalidOperationException("Client not connected to server.");
            }

            var tcpMessage = new TcpMessage(sendCounter, packet);

            await _stream.WriteAsync(tcpMessage.Encode(), 0, tcpMessage.Encode().Length, token).ConfigureAwait(false);

            sendCounter++;
        }