public Server Listen(int port, Reactor.Action <Exception> callback) { try { this.httplistener = new Reactor.Net.HttpListener(); this.httplistener.Prefixes.Add(string.Format("http://*:{0}/", port)); this.httplistener.Start(); this.GetContext(); callback(null); } catch (Exception exception) { if (exception is HttpListenerException) { callback(exception); } else { callback(exception); } } return(this); }
public static void GetContext(Reactor.Net.HttpListener listener, Action <Exception, Reactor.Net.HttpListenerContext> callback) { try { listener.BeginGetContext((result) => { try { var context = listener.EndGetContext(result); Loop.Post(() => { callback(null, context); }); } catch (Exception exception) { Loop.Post(() => { callback(exception, null); }); } }, null); } catch (Exception exception) { callback(exception, null); } }
public Server Listen(int port, Reactor.Action<Exception> callback) { try { this.httplistener = new Reactor.Net.HttpListener(); this.httplistener.Prefixes.Add(string.Format("http://*:{0}/", port)); this.httplistener.Start(); this.GetContext(); callback(null); } catch(Exception exception) { if(exception is HttpListenerException) { callback(exception); } else { callback(exception); } } return this; }