Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamingRequestHandler"/> class.
        /// </summary>
        /// <param name="bot">The bot for which we handle requests.</param>
        /// <param name="activityProcessor">The processor for incoming requests.</param>
        /// <param name="connection">Connection used to send requests to the transport.</param>
        /// <param name="audience">The specified recipient of all outgoing activities.</param>
        /// <param name="logger">Logger implementation for tracing and debugging information.</param>
        public StreamingRequestHandler(IBot bot, IStreamingActivityProcessor activityProcessor, StreamingConnection connection, string audience = null, ILogger logger = null)
        {
            _bot = bot ?? throw new ArgumentNullException(nameof(bot));
            _activityProcessor = activityProcessor ?? throw new ArgumentNullException(nameof(activityProcessor));
            _innerConnection   = connection ?? throw new ArgumentNullException(nameof(connection));
            _logger            = logger ?? NullLogger.Instance;

            Audience = audience;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamingRequestHandler"/> class and
        /// establishes a connection over a WebSocket to a streaming channel.
        /// </summary>
        /// <remarks>
        /// The audience represents the recipient at the other end of the StreamingRequestHandler's
        /// streaming connection. Some acceptable audience values are as follows:
        /// <list>
        /// <item>- For Public Azure channels, use <see cref="Microsoft.Bot.Connector.Authentication.AuthenticationConstants.ToChannelFromBotOAuthScope"/>.</item>
        /// <item>- For Azure Government channels, use <see cref="Microsoft.Bot.Connector.Authentication.GovernmentAuthenticationConstants.ToChannelFromBotOAuthScope"/>.</item>
        /// </list>
        /// </remarks>
        /// <param name="bot">The bot for which we handle requests.</param>
        /// <param name="activityProcessor">The processor for incoming requests.</param>
        /// <param name="socket">The base socket to use when connecting to the channel.</param>
        /// <param name="logger">Logger implementation for tracing and debugging information.</param>
        /// <param name="audience">The specified recipient of all outgoing activities.</param>
        public StreamingRequestHandler(IBot bot, IStreamingActivityProcessor activityProcessor, WebSocket socket, string audience, ILogger logger = null)
        {
            _bot = bot ?? throw new ArgumentNullException(nameof(bot));
            _activityProcessor = activityProcessor ?? throw new ArgumentNullException(nameof(activityProcessor));

            if (socket == null)
            {
                throw new ArgumentNullException(nameof(socket));
            }

            Audience         = audience;
            _logger          = logger ?? NullLogger.Instance;
            _innerConnection = new LegacyStreamingConnection(socket, _logger, ServerDisconnected);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamingRequestHandler"/> class and
        /// establishes a connection over a Named Pipe to a streaming channel.
        /// </summary>
        /// <remarks>
        /// The audience represents the recipient at the other end of the StreamingRequestHandler's
        /// streaming connection. Some acceptable audience values are as follows:
        /// <list>
        /// <item>- For Public Azure channels, use <see cref="Microsoft.Bot.Connector.Authentication.AuthenticationConstants.ToChannelFromBotOAuthScope"/>.</item>
        /// <item>- For Azure Government channels, use <see cref="Microsoft.Bot.Connector.Authentication.GovernmentAuthenticationConstants.ToChannelFromBotOAuthScope"/>.</item>
        /// </list>
        /// </remarks>
        /// <param name="bot">The bot for which we handle requests.</param>
        /// <param name="activityProcessor">The processor for incoming requests.</param>
        /// <param name="pipeName">The name of the Named Pipe to use when connecting to the channel.</param>
        /// <param name="logger">Logger implementation for tracing and debugging information.</param>
        /// <param name="audience">The specified recipient of all outgoing activities.</param>
        public StreamingRequestHandler(IBot bot, IStreamingActivityProcessor activityProcessor, string pipeName, string audience, ILogger logger = null)
        {
            _bot = bot ?? throw new ArgumentNullException(nameof(bot));
            _activityProcessor = activityProcessor ?? throw new ArgumentNullException(nameof(activityProcessor));
            _logger            = logger ?? NullLogger.Instance;

            if (string.IsNullOrWhiteSpace(pipeName))
            {
                throw new ArgumentNullException(nameof(pipeName));
            }

            Audience         = audience;
            _innerConnection = new LegacyStreamingConnection(pipeName, _logger, ServerDisconnected);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamingRequestHandler"/> class and
        /// establishes a connection over a Named Pipe to a streaming channel.
        /// </summary>
        /// <param name="bot">The bot for which we handle requests.</param>
        /// <param name="activityProcessor">The processor for incoming requests.</param>
        /// <param name="pipeName">The name of the Named Pipe to use when connecting to the channel.</param>
        /// <param name="logger">Logger implementation for tracing and debugging information.</param>
        public StreamingRequestHandler(IBot bot, IStreamingActivityProcessor activityProcessor, string pipeName, ILogger logger = null)
        {
            _bot = bot ?? throw new ArgumentNullException(nameof(bot));
            _activityProcessor = activityProcessor ?? throw new ArgumentNullException(nameof(activityProcessor));
            _logger            = logger ?? NullLogger.Instance;

            if (string.IsNullOrWhiteSpace(pipeName))
            {
                throw new ArgumentNullException(nameof(pipeName));
            }

            _conversations        = new ConcurrentDictionary <string, DateTime>();
            _userAgent            = GetUserAgent();
            _server               = new NamedPipeServer(pipeName, this);
            _serverIsConnected    = true;
            _server.Disconnected += Server_Disconnected;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamingRequestHandler"/> class and
        /// establishes a connection over a WebSocket to a streaming channel.
        /// </summary>
        /// <param name="bot">The bot for which we handle requests.</param>
        /// <param name="activityProcessor">The processor for incoming requests.</param>
        /// <param name="socket">The base socket to use when connecting to the channel.</param>
        /// <param name="logger">Logger implementation for tracing and debugging information.</param>
        public StreamingRequestHandler(IBot bot, IStreamingActivityProcessor activityProcessor, WebSocket socket, ILogger logger = null)
        {
            _bot = bot ?? throw new ArgumentNullException(nameof(bot));
            _activityProcessor = activityProcessor ?? throw new ArgumentNullException(nameof(activityProcessor));

            if (socket == null)
            {
                throw new ArgumentNullException(nameof(socket));
            }

            _logger               = logger ?? NullLogger.Instance;
            _conversations        = new ConcurrentDictionary <string, DateTime>();
            _userAgent            = GetUserAgent();
            _server               = new WebSocketServer(socket, this);
            _serverIsConnected    = true;
            _server.Disconnected += Server_Disconnected;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamingRequestHandler"/> class and
 /// establishes a connection over a Named Pipe to a streaming channel.
 /// </summary>
 /// <param name="bot">The bot for which we handle requests.</param>
 /// <param name="activityProcessor">The processor for incoming requests.</param>
 /// <param name="pipeName">The name of the Named Pipe to use when connecting to the channel.</param>
 /// <param name="logger">Logger implementation for tracing and debugging information.</param>
 public StreamingRequestHandler(IBot bot, IStreamingActivityProcessor activityProcessor, string pipeName, ILogger logger = null)
     : this(bot, activityProcessor, pipeName, null, logger)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamingRequestHandler"/> class and
 /// establishes a connection over a WebSocket to a streaming channel.
 /// </summary>
 /// <param name="bot">The bot for which we handle requests.</param>
 /// <param name="activityProcessor">The processor for incoming requests.</param>
 /// <param name="socket">The base socket to use when connecting to the channel.</param>
 /// <param name="logger">Logger implementation for tracing and debugging information.</param>
 public StreamingRequestHandler(IBot bot, IStreamingActivityProcessor activityProcessor, WebSocket socket, ILogger logger = null)
     : this(bot, activityProcessor, socket, null, logger)
 {
 }
Exemplo n.º 8
0
 public StreamingRequestHandlerSub(IBot bot, IStreamingActivityProcessor activityProcessor, WebSocket socket, string audience, ILogger logger = null, List <string> methodCalls = null)
     : base(bot, activityProcessor, socket, audience, logger)
 {
     _methodCalls = methodCalls;
 }