bool TryProcessSpecialCommand(HttpSocket s, string uri) { uri = uri.ToLowerInvariant(); switch (uri) { case "/bye!": s.WriteTextResponse(200, "plain", ":(", false); ThreadPool.QueueUserWorkItem(delegate { Thread.Sleep(100); Stop(); }); return(true); case "/ping!": s.WriteTextResponse(200, "plain", ":)", false); return(true); case "/sl.png!": s.WriteBinaryResponse(200, "image/png", GetResourceBytes("sl.png"), false); return(true); case "/slx.png!": s.WriteBinaryResponse(200, "image/png", GetResourceBytes("slx.png"), false); return(true); case "/style.css!": s.WriteTextResponse(200, "css", HtmlFormatter.Style, false); return(true); default: return(false); } }
bool TryProcessXapRequest(HttpSocket s, string path) { // must end with XAP if (string.Compare(Path.GetExtension(path), ".xap", StringComparison.OrdinalIgnoreCase) != 0) { return(false); } // XAP already there? if (File.Exists(path)) { return(false); } // Directory must be present string dir = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(path); if (!Directory.Exists(dir)) { return(false); } byte[] xapBytes = null; try { xapBytes = XapBuilder.XapToMemory(dir); } catch (Exception e) { s.WriteErrorResponse(500, "error generating XAP: " + e.Message); return(true); } s.WriteBinaryResponse(200, "application/x-zip-compressed", xapBytes, false); return(true); }
bool TryProcessXapRequest(HttpSocket s, string path) { // must end with XAP if (string.Compare(Path.GetExtension(path), ".xap", StringComparison.OrdinalIgnoreCase) != 0) return false; // XAP already there? if (File.Exists(path)) return false; // Directory must be present string dir = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(path); if (!Directory.Exists(dir)) return false; byte[] xapBytes = null; try { xapBytes = XapBuilder.XapToMemory(dir); } catch (Exception e) { s.WriteErrorResponse(500, "error generating XAP: " + e.Message); return true; } s.WriteBinaryResponse(200, "application/x-zip-compressed", xapBytes, false); return true; }
bool TryProcessSpecialCommand(HttpSocket s, string uri) { uri = uri.ToLowerInvariant(); switch (uri) { case "/bye!": s.WriteTextResponse(200, "plain", ":(", false); ThreadPool.QueueUserWorkItem(delegate { Thread.Sleep(100); Stop(); }); return true; case "/ping!": s.WriteTextResponse(200, "plain", ":)", false); return true; case "/sl.png!": s.WriteBinaryResponse(200, "image/png", GetResourceBytes("sl.png"), false); return true; case "/slx.png!": s.WriteBinaryResponse(200, "image/png", GetResourceBytes("slx.png"), false); return true; case "/style.css!": s.WriteTextResponse(200, "css", HtmlFormatter.Style, false); return true; default: return false; } }