Esempio n. 1
0
        public WebSocketMiddleware(RequestDelegate next, WebSocketOptions options)
        {
            _next = next;
            _options = options;

            // TODO: validate options.
        }
        public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app, WebSocketOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return app.UseMiddleware<WebSocketMiddleware>(options);
        }
        public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app, Action<WebSocketOptions> configureOptions)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (configureOptions == null)
            {
                throw new ArgumentNullException(nameof(configureOptions));
            }

            var options = new WebSocketOptions();
            configureOptions(options);

            return app.UseMiddleware<WebSocketMiddleware>(options);
        }
 public UpgradeHandshake(HttpContext context, IHttpUpgradeFeature upgradeFeature, WebSocketOptions options)
 {
     _context        = context;
     _upgradeFeature = upgradeFeature;
     _options        = options;
 }
Esempio n. 5
0
 public UpgradeHandshake(HttpContext context, IHttpUpgradeFeature upgradeFeature, WebSocketOptions options)
 {
     _context = context;
     _upgradeFeature = upgradeFeature;
     _options = options;
 }
 public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder, WebSocketOptions options) // TODO: [NotNull]
 {
     return builder.Use(next => new WebSocketMiddleware(next, options).Invoke);
 }