public ErrorHandlingBehaviour(IBotBehaviour <IClientEvent> next)
 {
     if (next == null)
     {
         throw new ArgumentNullException(nameof(next));
     }
     _next = next;
 }
示例#2
0
        public Bot(string botId, IClientConnection connection, params IBotBehaviour[] behaviours)
        {
            if (string.IsNullOrEmpty(botId))
            {
                throw new ArgumentException("Bot id cannot be null or empty.", nameof(botId));
            }
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            _state        = BotState.Idle;
            _context      = new BotContext(botId, connection, Stop, Notify);
            _subscription = connection.Events.Subscribe(OnClientEvent, OnClientException, OnClientCompleted);
            var allBehaviours = behaviours.ToList();
            var dispatcher    = new DispatcherBehaviour(allBehaviours);
            //var retry = new RetryBehaviour(dispatcher);
            var errorHandling = new ErrorHandlingBehaviour(dispatcher);
            var diagnostics   = new DiagnosticsBehaviour(errorHandling);

            _entryBehaviour = diagnostics;
            _received       = _context.Logger.CountOperation(ReceivedCounterName, resolution: ReceivedCounterResolution);
            Events          = Observable.Empty <IBotEvent>();
        }
 public DiagnosticsBehaviour(IBotBehaviour <IClientEvent> next)
 {
     _next = next ?? throw new ArgumentNullException(nameof(next));
 }