public static CommandsService CreateService(ServerConfiguration configuration) { var context = new ServerContext(configuration.Registry, configuration.Broker, configuration.StateProvider); var service = new CommandsService(context); return service; }
public static HttpConfiguration CreateServiceConfiguration(ServerConfiguration configuration) { var service = CreateService(configuration); var httpConfig = CreateConfiguration(service); if (configuration.ConfigureHttp != null) { configuration.ConfigureHttp(httpConfig); } return httpConfig; }
protected void Application_Start(object sender, EventArgs e) { var configuration = new ServerConfiguration { Registry = new ReflectionCommandRegistry(typeof(__SampleCommandsMarker).Assembly), Broker = new ReflectionCommandBroker(typeof(__SampleHandlersMarker).Assembly), ConfigureHttp = http => { /* some http specific stuff configuration could be added here */ } }; ZazServer.ConfigureAsWebHost("Commands", configuration); }
public static RouteCollection MapCommandsService(this RouteCollection @this, string prefix = "Commands/", ServerConfiguration configuration = null) { // Add / to the prefix, otherwise UI will not work prefix = prefix ?? ""; if (!prefix.EndsWith("/")) { prefix += "/"; } var config = ConfigurationHelper.CreateServiceConfiguration(configuration); @this.MapServiceRoute<CommandsService>(prefix, config); return @this; }
public void Given_command_server_runnig() { var serverConfiguration = new ServerConfiguration { Registry = new FooCommandRegistry(), Broker = new DelegatingCommandBroker((cmd, ctx) => { return Task.Factory.StartNew(() => { }); }), ConfigureHttp = http => http.SetupBasicAuthentication("supr", "booper", "") }; var config = ZazServer.ConfigureAsSelfHosted(URL, serverConfiguration); _host = new HttpSelfHostServer(config); _host.OpenAsync().Wait(); }
public void Given_command_server_runnig() { var serverConfiguration = new ServerConfiguration { Registry = new FooCommandRegistry(), Broker = new DelegatingCommandBroker((cmd, ctx) => { _postedCommand = cmd; _ctx = ctx; _principal = Thread.CurrentPrincipal; return Task.Factory.StartNew(() => { }); }), ConfigureHttp = http => http.SetupBasicAuthentication("supr", "booper", "") }; var config = ZazServer.ConfigureAsSelfHosted(URL, serverConfiguration); _host = new HttpSelfHostServer(config); //SimpleBasicAuthenticationHandler.Configure(config, cred => cred.UserName == "supr" && cred.Password == "booper"); using (new HttpSelfHostServer(config)) { _host.OpenAsync().Wait(); // Client side var configuration = new ZazConfiguration(); configuration.SetupSimpleBasicAuthentication("supr", "booper"); var client = new ZazClient(URL, configuration); client.PostAsync(new FooCommand { Message = "Hello world" }).Wait(); } }