Exemplo n.º 1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILog appLog, IApplicationLifetime appLifetime)
        {
            IWampHost        host  = ApplicationContainer.Resolve <IWampHost>();
            IWampHostedRealm realm = ApplicationContainer.Resolve <IWampHostedRealm>();
            var rpcMethods         = ApplicationContainer.Resolve <IRpcMethods>();


            appLifetime.ApplicationStopped.Register(() =>
            {
                ApplicationContainer.Dispose();
            });

            appLifetime.ApplicationStarted.Register(() =>
                                                    realm.Services.RegisterCallee(rpcMethods).Wait()
                                                    );

            app.UseMvc();
            app.UseSwagger();
            app.UseSwaggerUi("swagger/ui/index");

            app.Map("/ws", builder =>
            {
                builder.UseWebSockets(new WebSocketOptions {
                    KeepAliveInterval = TimeSpan.FromMinutes(1)
                });

                host.RegisterTransport(new AspNetCoreWebSocketTransport(builder),
                                       new JTokenJsonBinding());
            });

            host.Open();

            appLog.WriteInfoAsync("BoxOptionsServer", "Startup.Configure", null, string.Format("Lykke.BoxOptionsServer [{0}] started.", Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion));
        }
        public static void UseWampHost(this IApplicationBuilder app, IWampHost host)
        {
            app.Map("/ws", builder =>
            {
                builder.UseWebSockets(new WebSocketOptions {
                    KeepAliveInterval = TimeSpan.FromMinutes(1)
                });

                var jsonSettings = new JsonSerializerSettings();
                jsonSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
                var jsonSerializer = JsonSerializer.Create(jsonSettings);
                host.RegisterTransport(new AspNetCoreWebSocketTransport(builder),
                                       new JTokenJsonBinding(jsonSerializer),
                                       new JTokenMsgpackBinding(jsonSerializer));
            });

            host.Open();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Registers a given transport for a given host.
 /// </summary>
 /// <param name="host">The given host.</param>
 /// <param name="transport">The given transport to register.</param>
 /// <param name="binding">The given bindings to activate support with the given transport.</param>
 public static void RegisterTransport(this IWampHost host, IWampTransport transport,
                                      params IWampBinding[] binding)
 {
     host.RegisterTransport(transport, binding);
 }