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;
 }
Esempio n. 2
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;
 }
 public RecoverableEventMessageStream(
     TimeSpan oldStreamCloseTimeout,
     TimeSpan reconnectBackoff,
     int maxReconnectAttempts,
     GetStream getStreamDelegate,
     StreamOpenedAsync openDelegate,
     StreamClosedAsync closeDelegate,
     UnexpectedCloseDelegateAsync unexpectedCloseDelegate)
 {
     this.oldStreamCloseTimeout   = oldStreamCloseTimeout;
     this.reconnectBackoff        = reconnectBackoff;
     this.maxReconnectAttempts    = maxReconnectAttempts;
     this.getStreamDelegate       = getStreamDelegate;
     this.openDelegate            = openDelegate;
     this.closeDelegate           = closeDelegate;
     this.unexpectedCloseDelegate = unexpectedCloseDelegate;
 }