@@ -19,8 +19,7 @@ public abstract partial class RSocketService
1919
2020 public RSocketService ( RSocket socket ) { Socket = socket ; }
2121
22-
23- protected Task __RequestFireAndForget < TMessage > ( TMessage message , Func < TMessage , byte [ ] > messagemapper ,
22+ protected Task __RequestFireAndForget < TMessage > ( TMessage message , Func < TMessage , byte [ ] > messagemapper ,
2423 ReadOnlySequence < byte > metadata = default , ReadOnlySequence < byte > tracing = default , string service = default , [ CallerMemberName ] string method = default )
2524 => __RequestFireAndForget ( new ReadOnlySequence < byte > ( messagemapper ( message ) ) , metadata , tracing , service : service , method : method ) ;
2625
@@ -88,23 +87,24 @@ private protected IAsyncEnumerable<T> __RequestChannel<TMessage, T>(IAsyncEnumer
8887
8988 static System . Collections . Concurrent . ConcurrentDictionary < string , IRSocketService > Services = new System . Collections . Concurrent . ConcurrentDictionary < string , IRSocketService > ( ) ;
9089
91- static public void Register ( RSocket socket , IRSocketService service )
90+ static public void Register ( RSocket socket , IRSocketService service , Func < ReadOnlySequence < byte > , RSocketService . RemoteProcedureCallMetadata > metadataMapper = null )
9291 {
9392 Services [ service . ServiceName ] = service ;
9493
95- //TODO Need to ensure that this really only happens once per Socket.
94+ metadataMapper = metadataMapper ?? RemoteProcedureCallMetadata . create ;
95+ //TODO Need to ensure that this really only happens once per Socket.
9696
97- socket . Respond ( message => ( RPC : new RSocketService . RemoteProcedureCallMetadata ( message . Metadata ) , message . Data ) ,
97+ socket . Respond ( message => ( RPC : metadataMapper ( message . Metadata ) , message . Data ) ,
9898 request => Dispatch ( request . Data , request . RPC . Service , request . RPC . Method , request . RPC . Tracing , request . RPC . Metadata ) ,
9999 result => ( Data : result , Metadata : default ) ) ;
100100
101101 //TODO This looks data/metadata backwards?
102- socket . Stream ( message => ( RPC : new RSocketService . RemoteProcedureCallMetadata ( message . Metadata ) , message . Data ) ,
102+ socket . Stream ( message => ( RPC : metadataMapper ( message . Metadata ) , message . Data ) ,
103103 request => Dispatch ( request . Data , request . RPC . Service , request . RPC . Method , request . RPC . Tracing , request . RPC . Metadata ) ,
104104 result => ( Data : result , Metadata : default ) ) ;
105105
106106 socket . Channel ( ( request , messages ) => Dispatch ( request . Data , request . RPC . Service , request . RPC . Method , request . RPC . Tracing , request . RPC . Metadata , messages . ToAsyncEnumerable ( ) ) ,
107- message => ( RPC : new RSocketService . RemoteProcedureCallMetadata ( message . Metadata ) , message . Data ) ,
107+ message => ( RPC : metadataMapper ( message . Metadata ) , message . Data ) ,
108108 incoming => incoming . Data ,
109109 result => ( Data : result , Metadata : default ) ) ;
110110 }
0 commit comments