/// <summary> /// Connects the handler to a WebSocket server and begins listening for incoming requests. /// </summary> /// <param name="socket">The socket to use when creating the server.</param> /// <returns>A task that runs until the server is disconnected.</returns> public Task StartAsync(WebSocket socket) { _transportServer = new WebSocketServer(socket, this); return(_transportServer.StartAsync()); }
/// <summary> /// Connects the handler to a Named Pipe server and begins listening for incoming requests. /// </summary> /// <param name="pipeName">The name of the named pipe to use when creating the server.</param> /// <returns>A task that runs until the server is disconnected.</returns> public Task StartAsync(string pipeName) { _transportServer = new NamedPipeServer(pipeName, this); return(_transportServer.StartAsync()); }
/// <summary> /// Initializes a new instance of the <see cref="StreamingRequestHandler"/> class. /// The StreamingRequestHandler serves as a translation layer between the transport layer and bot adapter. /// It receives ReceiveRequests from the transport and provides them to the bot adapter in a form /// it is able to build activities out of, which are then handed to the bot itself to processed. /// Throws <see cref="ArgumentNullException"/> if arguments are null. /// </summary> /// <param name="onTurnError">Optional function to perform on turn errors.</param> /// <param name="bot">The <see cref="IBot"/> to be used for all requests to this handler.</param> /// <param name="middlewareSet">An optional set of middleware to register with the bot.</param> /// <param name="transportServer">An optional streaming transport server.</param> public StreamingRequestHandler(Func <ITurnContext, Exception, Task> onTurnError, IBot bot, IList <IMiddleware> middlewareSet = null, IStreamingTransportServer transportServer = null) { _onTurnError = onTurnError; _bot = bot ?? throw new ArgumentNullException(nameof(bot)); _middlewareSet = middlewareSet ?? new List <IMiddleware>(); UserAgent = GetUserAgent(); _transportServer = transportServer; }