public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData) { string data = inputData.ReadToEnd(); switch (p.http_url) { case "/songs/play": string songGuid = data.Replace("id=", string.Empty); HtmlData.OnPlaySong(songGuid); p.writeSuccess(); break; case "/songs/shuffle": HtmlData.OnShufflePlay(); p.writeSuccess(); break; case "/songs/playpause": HtmlData.OnPlayPause(); p.writeSuccess(); break; default: break; } }
public override void handleGETRequest(HttpProcessor p) { switch (p.http_url) { case "/close": p.writeSuccess(); p.outputStream.WriteLine(CloseDocument()); break; case "/": case "/songs": p.writeSuccess(); p.outputStream.WriteLine(SongsDocument()); break; case "/songs/current": p.writeSuccess(); p.outputStream.WriteLine(CurrentSongJson()); break; default: Console.WriteLine("request: {0}", p.http_url); p.writeSuccess(); p.outputStream.WriteLine("<html><body><h1>404 Not Found</h1>"); p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString()); p.outputStream.WriteLine("url : {0}", p.http_url); p.outputStream.WriteLine("</body></html>"); break; } }