private static void CreateSimplePipeline(DelegatePipelineFactory factory) { factory.AddUpstreamHandler(() => new HeaderDecoder()); factory.AddUpstreamHandler(() => new BodyDecoder()); factory.AddUpstreamHandler(new MyApplication()); factory.AddDownstreamHandler(new ResponseEncoder()); }
private static void CreateRpcPipeline(DelegatePipelineFactory factory) { var invoker = new RpcServiceInvoker(new DotNetValueConverter(), new SimpleServiceLocator()); invoker.Map<MathModule>(); factory.AddUpstreamHandler(() => new HeaderDecoder()); factory.AddUpstreamHandler(() => new BodyDecoder()); factory.AddUpstreamHandler(new RequestHandler(invoker)); factory.AddDownstreamHandler(new ResponseEncoder()); }
static void Main(string[] args) { LogManager.Assign(new SimpleLogManager<ConsoleLogger>()); var factory = new DelegatePipelineFactory(); //CreateSimplePipeline(factory); CreateRpcPipeline(factory); JsonRpcListener listener = new JsonRpcListener(factory); listener.Start(new IPEndPoint(IPAddress.Any, 3322)); Console.ReadLine(); }
private static void Main(string[] args) { LogManager.Assign(new SimpleLogManager<ConsoleLogger>()); var factory = new DelegatePipelineFactory(); //CreateSimplePipeline(factory); CreateRpcPipeline(factory); var server = new PipelineServer(factory, new ServerConfiguration()); server.Start(new IPEndPoint(IPAddress.Any, 3322)); Console.ReadLine(); }
private static void Main(string[] args) { LogManager.Assign(new SimpleLogManager <ConsoleLogger>()); var factory = new DelegatePipelineFactory(); //CreateSimplePipeline(factory); CreateRpcPipeline(factory); var server = new PipelineServer(factory, new ServerConfiguration()); server.Start(new IPEndPoint(IPAddress.Any, 3322)); Console.ReadLine(); }
public static void RunDemo() { var authService = new DummyAuthenticatorService(); var authHandler = new AuthenticationHandler( new DigestAuthenticator(new SingleRealmRepository("*****@*****.**"), authService), authService); var factory = new DelegatePipelineFactory(); factory.AddDownstreamHandler(authHandler); factory.AddDownstreamHandler(() => new ResponseEncoder()); factory.AddUpstreamHandler(() => new HeaderDecoder()); factory.AddUpstreamHandler(new HttpErrorHandler(new SimpleErrorFormatter())); factory.AddUpstreamHandler(authHandler); factory.AddUpstreamHandler(() => new BodyDecoder(new CompositeBodyDecoder(), 65535, 6000000)); //factory.AddUpstreamHandler(() => new FileHandler()); factory.AddUpstreamHandler(() => new MessageHandler()); //factory.AddUpstreamHandler(new PipelineFailureHandler()); var server = new PipelineServer(factory, new ServerConfiguration()); server.Start(new IPEndPoint(IPAddress.Any, 8888)); }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; LogManager.Assign(new SimpleLogManager <ConsoleLogger>()); /* * var cb = new ContainerBuilder(); * cb.RegisterType<HttpParser>().AsImplementedInterfaces().SingleInstance(); * cb.RegisterType<ResponseEncoder>().AsSelf().SingleInstance(); * cb.RegisterType<HeaderDecoder>().AsSelf().SingleInstance(); * cb.RegisterType<MessageHandler>().AsSelf().SingleInstance(); * cb.RegisterType<FileHandler>().AsSelf().SingleInstance(); * var serviceLocator = new AutofacServiceLocator(cb.Build()); */ var authService = new DummyAuthenticatorService(); var authHandler = new AuthenticationHandler(new DigestAuthenticator(new SingleRealmRepository("*****@*****.**"), authService), authService); var factory = new DelegatePipelineFactory(); factory.AddDownstreamHandler(authHandler); factory.AddDownstreamHandler(() => new ResponseEncoder()); factory.AddUpstreamHandler(() => new HeaderDecoder(new HttpParser())); factory.AddUpstreamHandler(new HttpErrorHandler(new SimpleErrorFormatter())); factory.AddUpstreamHandler(authHandler); factory.AddUpstreamHandler(() => new BodyDecoder(new CompositeBodyDecoder(), 65535, 6000000)); //factory.AddUpstreamHandler(() => new FileHandler()); factory.AddUpstreamHandler(() => new MessageHandler()); //factory.AddUpstreamHandler(new PipelineFailureHandler()); HttpListener listener = new HttpListener(factory); listener.Start(new IPEndPoint(IPAddress.Any, 8080)); Console.ReadLine(); }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; LogManager.Assign(new SimpleLogManager<ConsoleLogger>()); /* var cb = new ContainerBuilder(); cb.RegisterType<HttpParser>().AsImplementedInterfaces().SingleInstance(); cb.RegisterType<ResponseEncoder>().AsSelf().SingleInstance(); cb.RegisterType<HeaderDecoder>().AsSelf().SingleInstance(); cb.RegisterType<MessageHandler>().AsSelf().SingleInstance(); cb.RegisterType<FileHandler>().AsSelf().SingleInstance(); var serviceLocator = new AutofacServiceLocator(cb.Build()); */ var authService = new DummyAuthenticatorService(); var authHandler = new AuthenticationHandler(new DigestAuthenticator(new SingleRealmRepository("*****@*****.**"), authService), authService); var factory = new DelegatePipelineFactory(); factory.AddDownstreamHandler(authHandler); factory.AddDownstreamHandler(() => new ResponseEncoder()); factory.AddUpstreamHandler(() => new HeaderDecoder(new HttpParser())); factory.AddUpstreamHandler(new HttpErrorHandler(new SimpleErrorFormatter())); factory.AddUpstreamHandler(authHandler); factory.AddUpstreamHandler(() => new BodyDecoder(new CompositeBodyDecoder(), 65535, 6000000)); //factory.AddUpstreamHandler(() => new FileHandler()); factory.AddUpstreamHandler(() => new MessageHandler()); //factory.AddUpstreamHandler(new PipelineFailureHandler()); HttpListener listener = new HttpListener(factory); listener.Start(new IPEndPoint(IPAddress.Any, 8080)); Console.ReadLine(); }
public void Start() { try { var factory = new DelegatePipelineFactory(); factory.AddDownstreamHandler(() => new ResponseEncoder()); factory.AddUpstreamHandler(() => new HeaderDecoder(new HttpParser())); var decoder = new CompositeBodyDecoder(); decoder.Add("application/json", new JsonBodyDecoder()); decoder.Add("application/xml", new JsonBodyDecoder()); decoder.Add("application/x-gzip", new JsonBodyDecoder()); decoder.Add("application/llsd+json", new JsonBodyDecoder()); decoder.Add("application/llsd+xml", new JsonBodyDecoder()); decoder.Add("application/xml+llsd", new JsonBodyDecoder()); decoder.Add("application/octet-stream", new JsonBodyDecoder()); decoder.Add("text/html", new JsonBodyDecoder()); decoder.Add("text/xml", new JsonBodyDecoder()); decoder.Add("text/www-form-urlencoded", new JsonBodyDecoder()); decoder.Add("text/x-www-form-urlencoded", new JsonBodyDecoder()); factory.AddUpstreamHandler(() => new BodyDecoder(decoder, 65535, int.MaxValue)); factory.AddUpstreamHandler(() => (MessageHandler = new MessageHandler(this))); _httpListener = new HttpListener(factory); _httpListener.Start(new IPEndPoint(IPAddress.Any, (int)Port)); // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); HTTPDRunning = true; MainConsole.Instance.InfoFormat("[BASE HTTP SERVER]: Listening on port {0}", Port); } catch (Exception e) { MainConsole.Instance.Error("[BASE HTTP SERVER]: Error - " + e.Message); MainConsole.Instance.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + "?"); // We want this exception to halt the entire server since in current configurations we aren't too // useful without inbound HTTP. throw; } }