public async ValueTask SendSessionUpdateWindowSizeMessageAsync(SessionUpdateWindowSizeMessage sessionUpdateWindowSizeMessage, CancellationToken token = default) { await _connection.EnqueueAsync((bufferWriter) => { Varint.SetUInt64((byte)PacketType.Connect, bufferWriter); sessionUpdateWindowSizeMessage.Export(bufferWriter, _bufferPool); }, token); }
public void DoEvents() { _connection.DoEvents(); _connection.TryDequeue((sequence) => { if (!Varint.TryGetUInt64(sequence, out var type, out var comsumed)) { throw new FormatException(); } sequence = sequence.Slice(comsumed); switch ((PacketType)type) { case PacketType.Connect: this.ReceiveSessionConnectMessageEvent.Invoke(SessionConnectMessage.Import(sequence, _bufferPool)); break; case PacketType.Accept: this.ReceiveSessionAcceptMessageEvent.Invoke(SessionAcceptMessage.Import(sequence, _bufferPool)); break; case PacketType.UpdateWindowSize: this.ReceiveSessionUpdateWindowSizeMessageEvent.Invoke(SessionUpdateWindowSizeMessage.Import(sequence, _bufferPool)); break; case PacketType.Data: this.ReceiveSessionDataMessageEvent.Invoke(SessionDataMessage.Import(sequence, _bufferPool)); break; case PacketType.Close: this.ReceiveSessionCloseMessageEvent.Invoke(SessionCloseMessage.Import(sequence, _bufferPool)); break; case PacketType.Error: this.ReceiveSessionErrorMessageEvent.Invoke(SessionErrorMessage.Import(sequence, _bufferPool)); break; } }); }