public Task RequestResponse(IRSocketStream stream, ReadOnlySequence <byte> data, ReadOnlySequence <byte> metadata = default) { var id = StreamDispatch(stream); new RSocketProtocol.RequestResponse(id, data, metadata).Write(Transport.Output, data, metadata); var result = Transport.Output.FlushAsync(); return(result.IsCompleted ? Task.CompletedTask : result.AsTask()); }
public Task RequestStream(IRSocketStream stream, ReadOnlySequence <byte> data, ReadOnlySequence <byte> metadata = default, int initial = INITIALDEFAULT) { if (initial <= INITIALDEFAULT) { initial = Options.InitialRequestSize; } var id = StreamDispatch(stream); new RSocketProtocol.RequestStream(id, data, metadata, initialRequest: initial).Write(Transport.Output, data, metadata); var result = Transport.Output.FlushAsync(); return(result.IsCompleted ? Task.CompletedTask : result.AsTask()); }
public Task RequestChannel(IRSocketStream stream, ReadOnlySequence <byte> data, ReadOnlySequence <byte> metadata = default, int initial = INITIALDEFAULT) { if (initial <= INITIALDEFAULT) { initial = Options.InitialRequestSize; } var id = StreamDispatch(stream); //TODO This needs to be returned to the caller to allow them to send more messages. new RSocketProtocol.RequestChannel(id, data, metadata, initialRequest: initial).Write(Transport.Output, data, metadata); var result = Transport.Output.FlushAsync(); return(result.IsCompleted ? Task.CompletedTask : result.AsTask()); }
public Task RequestStream <TData, TMetadata>(IRSocketStream stream, TData data, TMetadata metadata = default, int initial = INITIALDEFAULT) => RequestStream(stream, RequestDataSerializer.Serialize(data), RequestMetadataSerializer.Serialize(metadata), initial);
public Task RequestStream <TMetadata>(IRSocketStream stream, ReadOnlySpan <byte> data, TMetadata metadata = default, int initial = INITIALDEFAULT) => RequestStream(stream, data, RequestMetadataSerializer.Serialize(metadata), initial);
//#region Default Serializers for Strings //public ValueTask<System.IO.Pipelines.FlushResult> RequestStream(IRSocketStream stream, Span<byte> data, string metadata = default, int initial = INITIALDEFAULT) => // RequestStream(stream, data, metadata: metadata == default ? default : Encoding.UTF8.GetBytes(metadata), initial: initial); //#endregion //TODO SPEC: A requester MUST not send PAYLOAD frames after the REQUEST_CHANNEL frame until the responder sends a REQUEST_N frame granting credits for number of PAYLOADs able to be sent. public Task RequestChannel <TData>(IRSocketStream stream, TData data, ReadOnlySpan <byte> metadata = default, int initial = INITIALDEFAULT) => RequestChannel(stream, RequestDataSerializer.Serialize(data), metadata, initial);
private int StreamDispatch(IRSocketStream transform) { var id = NewStreamId(); Dispatcher[id] = transform; return(id); }
public Task RequestResponse <TData, TMetadata>(IRSocketStream stream, TData data, TMetadata metadata = default) => RequestResponse(stream, RequestDataSerializer.Serialize(data), RequestMetadataSerializer.Serialize(metadata));
public Task RequestResponse <TMetadata>(IRSocketStream stream, ReadOnlySpan <byte> data, TMetadata metadata = default) => RequestResponse(stream, data, RequestMetadataSerializer.Serialize(metadata));
public Task RequestResponse <TData>(IRSocketStream stream, TData data, ReadOnlySpan <byte> metadata = default) => RequestFireAndForget(stream, RequestDataSerializer.Serialize(data), metadata);
public Task RequestFireAndForget <TData, TMetadata>(IRSocketStream stream, TData data, TMetadata metadata = default) => RequestFireAndForget(stream, RequestDataSerializer.Serialize(data), RequestMetadataSerializer.Serialize(metadata));
public Task RequestFireAndForget <TMetadata>(IRSocketStream stream, ReadOnlySpan <byte> data, TMetadata metadata = default) => RequestFireAndForget(stream, data, RequestMetadataSerializer.Serialize(metadata));