private void OnConnect(ConnectedEventArgs args) { this.httpResponseHandler = new HttpResponseHandler(args.Writer) { IsIrcConnected = true }; this.server = new HttpServer(config, this.httpResponseHandler); this.server.OnStatus += this.Status; this.server.OnError += this.ErrorStatus; this.server.Start(); this.Status("HTTP Server Started"); }
// ---------------- Constructor ---------------- public HttpServer(HttpServerConfig config, HttpResponseHandler responseHandler) { this.isDisposed = false; this.isListening = false; this.isListeningLock = new object(); ArgumentChecker.IsNotNull(config, nameof(config)); config.Validate(); if (HttpListener.IsSupported == false) { throw new PlatformNotSupportedException( "This platform does not support HTTP Listeners..." ); } this.listener = new HttpListener(); this.listener.Prefixes.Add("http://localhost:" + config.Port + "/"); this.responseHandler = responseHandler; this.listenThread = new Thread(this.HandleRequestThreadEntry); this.listenThread.Name = "Http Server Thread"; }