public WebServer(string listenerPrefix, Router router) { if (!HttpListener.IsSupported) { throw new NotSupportedException("The HttpListener class is not supported on this operating system."); } if (listenerPrefix == null) { throw new ArgumentNullException("listenerPrefix"); } this.UniqueId = Guid.NewGuid(); this._listener = new HttpListener(); this._listener.Prefixes.Add(listenerPrefix); this.IncomingRequest +=new EventHandler<HttpRequestEventArgs>(router.IncomingRequest); }
public PlexServer(string ServerTestUrl) { Router router = new Router(); router.AddController("library", new Library()); router.AddController("resources", new Resources()); router.AddController("manage", new Manage()); listener = new WebServer(ServerTestUrl, router); listener.Start(); String domain = ""; String type = "_plexmediasvr._tcp"; String name = "WinPlex Media Server"; int port = 32400; NetService publishService = new NetService(domain, type, name, port); /* HARDCODE TXT RECORD */ System.Collections.Hashtable dict = new System.Collections.Hashtable(); dict.Add("txtvers", "1"); publishService.TXTRecordData = NetService.DataFromTXTRecordDictionary(dict); publishService.Publish(); }