/// <summary> /// Creates IChannelServerManager instance /// </summary> /// <param name="serverAction">IChannelServer options</param> public static IChannelServerManager Build(Action <IChannelServer> serverAction) { //Its important to initialise service locator before ChannelServer for the speed var locator = ServiceLocatorBuilder.CreateServiceLocator(KnownExportAssemblies); var server = ChannelServerBuilder.CreateServer(); serverAction(server); return(new ServerManager(locator, server)); }
/// <summary> /// Creates IChannelWebServer instance /// </summary> /// <param name="serverAction">IChannelServer options</param> /// <param name="assemblies">Assemblies containing exported services</param> public static IChannelWebServer Build(Action <IChannelServer> serverAction) { var locator = ServiceLocatorBuilder.CreateServiceLocator(KnownExportAssemblies); var authenticationService = ServiceFactory.GetExportedService <IAuthenticationService>(); var server = ChannelServerBuilder.CreateServer(); server.AddBasicAuthentication(authenticationService.AuthenticateUser); serverAction(server); return(new ChannelWebServer(locator, server)); }
static void Main(string[] args) { AuthMethods authMethods = new AuthMethods(); IChannelServer host = ChannelServerBuilder.CreateServer(); host.LoadAssemblies(AppDomain.CurrentDomain, null); host.AddTokenAuthentication(authMethods.AuthenticateToken); host.StartHosting(null); Console.ReadLine(); }
/// <summary> /// Creates IChannelServerManager instance /// </summary> /// <param name="serverAction">IChannelServer options</param> /// <param name="exportAssemblies">Additional assemblies containing exported services</param> /// <returns></returns> public static IChannelServerManager Build(Action <IChannelServer> serverAction, List <string> exportAssemblies) { //Its important to initialise IServiceLocator before ChannelServer for the speed if (exportAssemblies != null && exportAssemblies.Count > 0) { KnownExportAssemblies.AddRange(exportAssemblies); } var locator = ServiceLocatorBuilder.CreateServiceLocator(KnownExportAssemblies); var server = ChannelServerBuilder.CreateServer(); serverAction(server); return(new ServerManager(locator, server)); }
static void Main(string[] args) { AuthMethods authMethods = new AuthMethods(); IChannelServer host = ChannelServerBuilder.CreateServer(); //host.LoadAssemblies(AppDomain.CurrentDomain, null); List <string> asm = new List <string> { "Nuclear.Channels.Monolithic.Tests" }; host.RegisterChannels(asm); host.AddTokenAuthentication(authMethods.AuthenticateToken); //host.ConfigureCacheCleaner(TimeSpan.FromSeconds(30)); host.StartHosting(null); Console.ReadLine(); }
public static IApplicationBuilder UseChannels(this IApplicationBuilder app) { IChannelServer server = ChannelServerBuilder.CreateServer(); //If you have channels or services in another project add them into your current AppDomain //Same goes for services if you use IServiceLocator from Nuclear.ExportLocator package server.LoadAssemblies(AppDomain.CurrentDomain); //Add authentication if you have for basic or for token authentication //server.AddTokenAuthentication( // your delegate goes here ); //server.AddBasicAuthentication( // your delegate goes here ); //or setup server.AuthenticationOption //Change the route for your web url server.StartHosting("https://localhost:44386"); return(app); }