Ejemplo n.º 1
0
 protected abstract Task OnMessageAsync(MessageDirection direction, uint messageId, RfpIdentifier rfp, Memory <byte> data, CancellationToken cancellationToken);
Ejemplo n.º 2
0
        public virtual async Task WriteAsync(MessageDirection direction, uint messageId, RfpIdentifier rfp, ReadOnlyMemory <byte> data, CancellationToken cancellationToken)
        {
            var header = new byte[4 + 1 + 4 + RfpIdentifier.Length];

            BinaryPrimitives.WriteUInt32BigEndian(header, (uint)(1 + 4 + RfpIdentifier.Length + data.Length));
            header[4] = (byte)direction;
            BinaryPrimitives.WriteUInt32BigEndian(header.AsSpan(5), messageId);
            rfp.CopyTo(header.AsSpan(4 + 1 + 4));
            await _socket.SendAsync(header, SocketFlags.None, cancellationToken).ConfigureAwait(false);

            await _socket.SendAsync(data, SocketFlags.None, cancellationToken).ConfigureAwait(false);
        }