示例#1
0
 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;
     }
 }
示例#2
0
        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;
            }
        }
示例#3
0
 public void Listen()
 {
     listener = new TcpListener(port);
     listener.Start();
     while (IsActive)
     {
         TcpClient s = listener.AcceptTcpClient();
         HttpProcessor processor = new HttpProcessor(s, this);
         Thread thread = new Thread(new ThreadStart(processor.process));
         thread.Start();
         Thread.Sleep(1);
     }
 }
示例#4
0
 public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
示例#5
0
 public abstract void handleGETRequest(HttpProcessor p);
示例#6
0
 public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
示例#7
0
 public abstract void handleGETRequest(HttpProcessor p);