public static IServerBuilder UseMessagePack(this IServerBuilder serverBuilder) { var serviceCollection = serverBuilder.GetServiceCollection(); serviceCollection.AddSingleton <IPacketSerialiser, MessagePackPacketSerialiser>(); return(serverBuilder); }
/// <summary> /// Makes the x42 server use all the required features - <see cref="BaseFeature" />. /// </summary> /// <param name="serverBuilder">Builder responsible for creating the server.</param> /// <returns>x42 server builder's interface to allow fluent code.</returns> public static IServerBuilder UseBaseFeature(this IServerBuilder serverBuilder) { serverBuilder.ConfigureFeature(features => { features .AddFeature <BaseFeature>() .FeatureServices(services => { services.AddSingleton(serverBuilder.ServerSettings.LoggerFactory); services.AddSingleton(serverBuilder.ServerSettings.DataFolder); services.AddSingleton <IX42ServerLifetime, X42ServerLifetime>(); services.AddSingleton <ServerFeatureExecutor>(); services.AddSingleton <X42Server>().AddSingleton(provider => { return(provider.GetService <X42Server>() as IX42Server); }); services.AddSingleton(DateTimeProvider.Default); services.AddSingleton <IAsyncLoopFactory, AsyncLoopFactory>(); // Console services.AddSingleton <IServerStats, ServerStats>(); }); }); return(serverBuilder); }
public void Register(string name, IServerBuilder builder) { if (Servers.ContainsKey(name)) { throw new ServerRegistrationException($"The server '{name}' has already been registered with the server registry. Perhaps you are accidentally including it in more than one IRegisterServers implementation."); } Servers.Add(name, builder); }
public ServerMain(IServerBuilder serverBuilder, IPacketRegistrator packetRegistrator) { _packetRegistrator = packetRegistrator; _serverContainer = serverBuilder.Build(); _serverContainer.ConnectionLost += ServerConnectionLost; _serverContainer.ConnectionEstablished += ServerServerEstablished; }
public static IServerBuilder UseProtobufNet(this IServerBuilder serverBuilder) { var serviceCollection = serverBuilder.GetServiceCollection(); serviceCollection.AddSingleton <IPacketSerialiser, ProtoBufNetSerialiser>(); return(serverBuilder); }
public static IServerBuilder UseZeroFormatter(this IServerBuilder serverBuilder) { var serviceCollection = serverBuilder.GetServiceCollection(); serviceCollection.AddSingleton <IPacketSerialiser, ZeroFormatterPacketSerialiser>(); return(serverBuilder); }
private void WhenSetLeaderSetup() { try { _serverBuilder = _services.AddFaXianZhe(_configRoot).SetLeader(); } catch (Exception ex) { _ex = ex; } }
private void WhenWithoutConfigSetup() { try { _serverBuilder = _services.AddFaXianZhe(); } catch (Exception ex) { _ex = ex; } }
public void Init() { NinjectConfig.RebindAction = kernel => { kernel.Rebind<IRepository<Book>>().ToConstant(MocksFactory.BooksRepository); kernel.Rebind<IRepository<Author>>().ToConstant(MocksFactory.AuthorsRepository); }; MyWebApi.Server().Starts<Startup>(); this.server = MyWebApi.Server().Working(); }
public void Init() { NinjectConfig.RebindAction = kernel => { kernel.Rebind <IRepository <Book> >().ToConstant(MocksFactory.BooksRepository); kernel.Rebind <IRepository <Author> >().ToConstant(MocksFactory.AuthorsRepository); kernel.Rebind <ApplicationUserManager>().ToConstant(MocksFactory.ApplicationUserManager); }; this.server = MyWebApi.Server().Starts <Startup>(); this.GetAccessToken(); }
public void Init() { NinjectConfig.RebindAction = kernel => { kernel.Rebind<IRepository<Book>>().ToConstant(MocksFactory.BooksRepository); kernel.Rebind<IRepository<Author>>().ToConstant(MocksFactory.AuthorsRepository); kernel.Rebind<ApplicationUserManager>().ToConstant(MocksFactory.ApplicationUserManager); }; this.server = MyWebApi.Server().Starts<Startup>(); this.GetAccessToken(); }
public void Initialize() { NinjectConfig.RebindAction = kernel => { kernel.Rebind<IRepository<Category>>().ToConstant(MocksFactory.GetCategoriesRepository()); kernel.Rebind<ICategoriesService>().ToConstant(MocksFactory.GetCategoriesService()); kernel.Rebind<ApplicationUserManager>().ToConstant(MocksFactory.ApplicationUserManager); }; this.server = MyWebApi.Server().Starts<Startup>(); //// this.GetAccessToken(); AutoMapper.Mapper.CreateMap<Category, CategoryDataTransferModel>(); }
public ApiFeature( IServerBuilder x42ServerBuilder, X42Server x42Server, ApiFeatureOptions apiFeatureOptions, ApiSettings apiSettings, ILoggerFactory loggerFactory, ICertificateStore certificateStore) { serverBuilder = x42ServerBuilder; this.x42Server = x42Server; this.apiFeatureOptions = apiFeatureOptions; this.apiSettings = apiSettings; this.certificateStore = certificateStore; logger = loggerFactory.CreateLogger(GetType().FullName); }
/// <summary> /// Makes the x42 server builder use specific server settings. /// </summary> /// <param name="builder">x42 server builder to change server settings for.</param> /// <param name="serverSettings">Server settings to be used.</param> /// <returns>Interface to allow fluent code.</returns> public static IServerBuilder UseServerSettings(this IServerBuilder builder, ServerSettings serverSettings) { ServerBuilder serverBuilder = builder as ServerBuilder; serverBuilder.ServerSettings = serverSettings; serverBuilder.ServerNode = serverSettings.ServerNode; builder.ConfigureServices(service => { service.AddSingleton(serverBuilder.ServerSettings); service.AddSingleton(serverBuilder.ServerNode); }); return(builder.UseBaseFeature()); }
/// <summary> /// Adds SQL components to the server. /// </summary> /// <param name="serverBuilder">The object used to build the current node.</param> /// <returns>The server builder, enriched with the new component.</returns> public static IServerBuilder UseSql(this IServerBuilder serverBuilder) { LoggingConfiguration.RegisterFeatureNamespace <DatabaseFeatures>("database"); serverBuilder.ConfigureFeature(features => { features .AddFeature <DatabaseFeatures>() .FeatureServices(services => { services.AddSingleton <DatabaseFeatures>(); services.AddSingleton <DatabaseSettings>(); }); }); return(serverBuilder); }
/// <summary> /// Adds x42 Client components to the server. /// </summary> /// <param name="serverBuilder">The object used to build the current node.</param> /// <returns>The server builder, enriched with the new component.</returns> public static IServerBuilder UseX42Client(this IServerBuilder serverBuilder) { LoggingConfiguration.RegisterFeatureNamespace <X42ClientFeature>("x42client"); serverBuilder.ConfigureFeature(features => { features .AddFeature <X42ClientFeature>() .FeatureServices(services => { services.AddSingleton <X42ClientFeature>(); services.AddSingleton <X42ClientSettings>(); }); }); return(serverBuilder); }
/// <summary> /// Adds profile components to the server. /// </summary> /// <param name="serverBuilder">The object used to build the current node.</param> /// <returns>The server builder, enriched with the new component.</returns> public static IServerBuilder UseProfile(this IServerBuilder serverBuilder) { LoggingConfiguration.RegisterFeatureNamespace <ProfileFeature>("profile"); serverBuilder.ConfigureFeature(features => { features .AddFeature <ProfileFeature>() .DependOn <DatabaseFeatures>() .FeatureServices(services => { services.AddSingleton <ProfileFeature>(); }); }); return(serverBuilder); }
/// <summary> /// Adds network components to the server. /// </summary> /// <param name="serverBuilder">The object used to build the current node.</param> /// <returns>The server builder, enriched with the new component.</returns> public static IServerBuilder UseNetwork(this IServerBuilder serverBuilder) { LoggingConfiguration.RegisterFeatureNamespace <NetworkFeatures>("network"); serverBuilder.ConfigureFeature(features => { features .AddFeature <NetworkFeatures>() .DependOn <DatabaseFeatures>() .FeatureServices(services => { services.AddSingleton <NetworkFeatures>(); services.AddSingleton <NetworkSettings>(); }); }); return(serverBuilder); }
public static IServerBuilder UseApi(this IServerBuilder serverBuilder, Action <ApiFeatureOptions> optionsAction = null) { // TODO: move the options in to the feature builder ApiFeatureOptions options = new ApiFeatureOptions(); optionsAction?.Invoke(options); serverBuilder.ConfigureFeature(features => { features .AddFeature <ApiFeature>() .FeatureServices(services => { services.AddSingleton(serverBuilder); services.AddSingleton(options); services.AddSingleton <ApiSettings>(); services.AddSingleton <ICertificateStore, CertificateStore>(); }); }); return(serverBuilder); }
protected IServerBuilder AddDefaultSettings(IServerBuilder builder, NetConnectionParameters parameters) { var config = (IConfiguration)Services.GetService(typeof(IConfiguration)); var tcpPort = (parameters.TcpPort > 0) ? parameters.TcpPort : config.GetValue <int>("Network:TcpPort"); var udpPort = (parameters.UdpPort > 0) ? parameters.UdpPort : config.GetValue <int>("Network:UdpPort"); return(builder .UseTcp(tcpPort) .UseUdp(udpPort) .UseZeroFormatter() .UseConfiguration(config) .ConfigureLogging(logBuilder => { logBuilder.AddConfiguration(config.GetSection("Logging")); logBuilder.AddConsole(); }) .RegisterTypes(serviceCollection => { serviceCollection.AddSingleton(c => this); serviceCollection.AddSingleton(c => this.Chat); this.RegisterTypes(serviceCollection); })); }
public static IServerBuilder UseNoql(this IServerBuilder serverBuilder) { throw new NotImplementedException("NoSQL is not yet supported"); }
public Server(IServerBuilder server, ClientsViewModel clientVm) { _clientVm = clientVm; _serverBuilder = server; }
public void TestInit() { server = MyWebApi.Server().Starts<Startup>(); }
/// <summary> /// Called before building the <see cref="IServer"/>. /// </summary> /// <param name="builder">The server builder.</param> protected virtual void OnServerBuild(IServerBuilder builder) { builder .RegisterPacketHandler <User.Packets.LoginPacket, LoginServerHandler <TUser> >() .RegisterPacketHandler <Chat.Packets.ChatPacket, ChatServerHandler <TUser> >(); }
public ServerDirector(IServerBuilder serverBuilder) { ServerBuilder = serverBuilder ?? throw new ArgumentNullException(nameof(serverBuilder)); }
/// <summary> /// Makes the x42 server builder use the default server settings. /// </summary> /// <param name="builder">x42 server builder to change server settings for.</param> /// <returns>Interface to allow fluent code.</returns> public static IServerBuilder UseDefaultServerSettings(this IServerBuilder builder) { return(builder.UseServerSettings(ServerSettings.Default(builder.ServerNode))); }
public static void Init(TestContext testContext) { server = MyWebApi.Server().Starts<Startup>(); }
public static void Init(TestContext testContext) { server = MyWebApi.Server().Starts <Startup>(); }
public ServerTests() { httpServer = MyHttpServer.WorkingRemotely(BaseAddress); }
public Server(IServerBuilder server) { _serverBuilder = server; }
public void Init() { _server = MyWebApi.Server().Starts <Startup>(); }