예제 #1
0
 public static IDuplexMessageStream MakeReadOnly(this IDuplexMessageStream wrapped)
 {
     if (wrapped is ReadOnlyDuplexMessageStream)
     {
         return(wrapped);
     }
     return(new ReadOnlyDuplexMessageStream(wrapped));
 }
예제 #2
0
 /// <summary>
 /// </summary>
 /// <param name="writerCloseTimeout">How long should we wait for the writer to finish writing data before closing</param>
 public MessageStream(
     IMessageDeserializer <T> deserializer,
     IMessageSerializer <T> serializer,
     IDuplexMessageStream duplexMessageStream,
     MessageStreamOptions options = null
     )
 {
     this.Deserializer        = deserializer;
     this.Serializer          = serializer;
     this.duplexMessageStream = duplexMessageStream;
     this.options             = options ?? new MessageStreamOptions();
 }
 public ConcurrentMessageStream(
     IMessageDeserializer <T> deserializer,
     IMessageSerializer <T> serializer,
     IDuplexMessageStream duplexMessageStream,
     UnexpectedCloseDelegateAsync unexpectedCloseDelegate,
     ConcurrentMessageStreamOptions options        = null,
     RequestResponseKeyResolver <T> rpcKeyResolver = null)
     : base(deserializer, serializer, duplexMessageStream, options ?? new ConcurrentMessageStreamOptions())
 {
     this.unexpectedCloseDelegateAsync = unexpectedCloseDelegate;
     this.concurrentOptions            = this.options as ConcurrentMessageStreamOptions;
     this.rpcKeyResolver = rpcKeyResolver;
 }
예제 #4
0
 /// <summary>
 /// </summary>
 /// <param name="handleMessageDelegate">Handles messages</param>
 /// <param name="handleDisconnectionDelegate">Called when there is a problem with the reader. The stream will be closed before this is called.</param>
 /// <param name="handleKeepAliveDelegate">Useful if you need to keep writing data every xxx seconds</param>
 /// <param name="numReaders">How many tasks to spawn to read from the channel</param>
 /// <param name="handleMessagesAsynchronously">
 /// Set this to true if you are using a bounded reader channel and you call WriteRequestAsync inside of your handleMessageDelegate.
 /// If you leave it false, you can run into a situation where your reader channel is being throttled, so the responses for WriteRequest will never come back,
 /// which will cause even more blocking on the whole read pipeline.
 /// </param>
 /// <param name="keepAliveTimeSpan">How long until we wait until we invoke the keep alive delegate. Default is 30 seconds.</param>
 public EventMessageStream(
     IMessageDeserializer <T> deserializer,
     IMessageSerializer <T> serializer,
     IDuplexMessageStream duplexMessageStream,
     HandleMessageAsync handleMessageDelegate,
     HandleKeepAliveAsync handleKeepAliveDelegate,
     UnexpectedCloseDelegateAsync unexpectedCloseDelegate,
     EventMessageStreamOptions options             = null,
     RequestResponseKeyResolver <T> rpcKeyResolver = null)
     : base(deserializer, serializer, duplexMessageStream, unexpectedCloseDelegate, options ?? new EventMessageStreamOptions(), rpcKeyResolver)
 {
     this.eventOptions            = this.options as EventMessageStreamOptions;
     this.handleMessageDelegate   = handleMessageDelegate;
     this.handleKeepAliveDelegate = handleKeepAliveDelegate;
 }
예제 #5
0
 internal ReadOnlyDuplexMessageStream(IDuplexMessageStream wrapped)
 {
     this.wrapped = wrapped;
 }