Example #1
0
        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());
        }
Example #2
0
        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());
        }
Example #3
0
        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());
        }
Example #4
0
 public Task RequestStream <TData, TMetadata>(IRSocketStream stream, TData data, TMetadata metadata        = default, int initial = INITIALDEFAULT) => RequestStream(stream, RequestDataSerializer.Serialize(data), RequestMetadataSerializer.Serialize(metadata), initial);
Example #5
0
 public Task RequestStream <TMetadata>(IRSocketStream stream, ReadOnlySpan <byte> data, TMetadata metadata = default, int initial = INITIALDEFAULT) => RequestStream(stream, data, RequestMetadataSerializer.Serialize(metadata), initial);
Example #6
0
        //#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);
Example #7
0
 private int StreamDispatch(IRSocketStream transform)
 {
     var id = NewStreamId(); Dispatcher[id] = transform; return(id);
 }
Example #8
0
 public Task RequestResponse <TData, TMetadata>(IRSocketStream stream, TData data, TMetadata metadata        = default) => RequestResponse(stream, RequestDataSerializer.Serialize(data), RequestMetadataSerializer.Serialize(metadata));
Example #9
0
 public Task RequestResponse <TMetadata>(IRSocketStream stream, ReadOnlySpan <byte> data, TMetadata metadata = default) => RequestResponse(stream, data, RequestMetadataSerializer.Serialize(metadata));
Example #10
0
 public Task RequestResponse <TData>(IRSocketStream stream, TData data, ReadOnlySpan <byte> metadata         = default) => RequestFireAndForget(stream, RequestDataSerializer.Serialize(data), metadata);
Example #11
0
 public Task RequestFireAndForget <TData, TMetadata>(IRSocketStream stream, TData data, TMetadata metadata        = default) => RequestFireAndForget(stream, RequestDataSerializer.Serialize(data), RequestMetadataSerializer.Serialize(metadata));
Example #12
0
 public Task RequestFireAndForget <TMetadata>(IRSocketStream stream, ReadOnlySpan <byte> data, TMetadata metadata = default) => RequestFireAndForget(stream, data, RequestMetadataSerializer.Serialize(metadata));