public static IApplicationBuilder UseRedisMessagingHub(this IApplicationBuilder app) { app.UseWebSockets(); return(app.Use(async(context, next) => { if (context.WebSockets.IsWebSocketRequest) { WebSocketService webSocketService = context.RequestServices.GetService <WebSocketService>(); await webSocketService.StartSocketListener(context); } else { await next.Invoke(); } })); }