public static void Main() { var messageBytes = Encoding.UTF8.GetBytes("Bunã lume!"); var handler = new Handler(messageBytes); var site = new MicroWebSite { Port = 1234, Handler = handler }; var server = new MicroWebServer(site, 64); server.Start(); }
public MicroWebServer(MicroWebSite microWebSite, int queueLength) { if (microWebSite == null) throw new ArgumentNullException("microWebSite"); if (queueLength < 8 || queueLength > 64) throw new ArgumentOutOfRangeException("queueLength"); _queueLength = queueLength; _handler = microWebSite.Handler; _requestQueue = new Queue(); _listenThread = new Thread(Listen); _processThread = new Thread(Process); var protocolPrefix = microWebSite.Https ? "https" : "http"; _listener = new HttpListener(protocolPrefix, microWebSite.Port); }