Example #1
0
 public static IServiceCollection AddFusionWebSocketServer(this IServiceCollection services,
                                                           WebSocketServer.Options options)
 {
     services.TryAddSingleton(options);
     services.TryAddSingleton <WebSocketServer>();
     return(services.AddFusionServerCore());
 }
        // ConfigureXxx

        public FusionWebSocketServerBuilder ConfigureWebSocketServer(
            WebSocketServer.Options options)
        {
            var serviceDescriptor = new ServiceDescriptor(
                typeof(WebSocketServer.Options),
                options);

            Services.Replace(serviceDescriptor);
            return(this);
        }
Example #3
0
 public static IServiceCollection AddFusionWebSocketServer(this IServiceCollection services,
                                                           Action <IServiceProvider, WebSocketServer.Options>?optionsBuilder = null)
 {
     services.TryAddSingleton(c => {
         var options = new WebSocketServer.Options();
         optionsBuilder?.Invoke(c, options);
         return(options);
     });
     services.TryAddSingleton <WebSocketServer>();
     return(services.AddFusionServerCore());
 }
        public FusionWebSocketServerBuilder ConfigureWebSocketServer(
            Action <IServiceProvider, WebSocketServer.Options> optionsBuilder)
        {
            var serviceDescriptor = new ServiceDescriptor(
                typeof(WebSocketServer.Options),
                c => {
                var options = new WebSocketServer.Options();
                optionsBuilder.Invoke(c, options);
                return(options);
            },
                ServiceLifetime.Singleton);

            Services.Replace(serviceDescriptor);
            return(this);
        }