Esempio n. 1
0
        public override void handleGETRequest(HttpProcessor p)
        {
            if (p.http_url.StartsWith("/disp")) {
                byte[] data = ImgSource.GetImage();
                p.httpResponseHeaders["Cache-Control"] = "no-cache, must-revalidate";
                p.writeSuccess("image/jpeg");
                p.outputStream.Flush();
                p.outputStream.BaseStream.Write(data,0,data.Length);
                p.outputStream.BaseStream.Flush();
            }
            else if (p.http_url.StartsWith("/left")) {
                byte[] data = ImgSource.GetLeftImage();
                p.httpResponseHeaders["Cache-Control"] = "no-cache, must-revalidate";
                p.writeSuccess("image/jpeg");
                p.outputStream.Flush();
                p.outputStream.BaseStream.Write(data,0,data.Length);
                p.outputStream.BaseStream.Flush();
            }
            else if (p.http_url.StartsWith("/right")) {
                byte[] data = ImgSource.GetRightImage();
                p.httpResponseHeaders["Cache-Control"] = "no-cache, must-revalidate";
                p.writeSuccess("image/jpeg");
                p.outputStream.Flush();
                p.outputStream.BaseStream.Write(data,0,data.Length);
                p.outputStream.BaseStream.Flush();
            }
            else if (p.http_url == "/main.css") {
                p.writeSuccess("text/css");
                string txt = File.ReadAllText("Server/main.css");
                p.outputStream.Write(txt);
            }
            else if (p.http_url == "/jquery.js") {
                p.writeSuccess("text/javascript");
                string txt = File.ReadAllText("Server/jquery.js");
                p.outputStream.Write(txt);

            }
            else if (p.http_url == "/main.js") {
                p.writeSuccess("text/javascript");
                string txt = File.ReadAllText("Server/main.js");
                p.outputStream.Write(txt);
            }
            else if (p.http_url == "" || p.http_url == "/" || p.http_url == "/index") {
                p.writeSuccess();
                string txt = File.ReadAllText("Server/main.html");
                p.outputStream.Write(txt);
            } else {
                p.writeSuccess();
                p.outputStream.Write(p.http_url);
            }
        }
Esempio n. 2
0
 public override void handlePOSTRequest(HttpProcessor p, System.IO.StreamReader inputData)
 {
 }
Esempio n. 3
0
 public void listen()
 {
     listener = new TcpListener(IPAddress.Any,port);
     listener.Start();
     while (is_active) {
         if (listener.Pending()) {
             TcpClient s = listener.AcceptTcpClient();
             s.SendTimeout = 120*1000; //milliseconds
             HttpProcessor processor = new HttpProcessor(s, this);
             Thread thread = new Thread(new ThreadStart(processor.process));
             thread.Start();
         }
         Thread.Sleep(100);
     }
     listener.Stop();
 }
Esempio n. 4
0
 public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
Esempio n. 5
0
 public abstract void handleGETRequest(HttpProcessor p);
Esempio n. 6
0
 public override void handlePOSTRequest(HttpProcessor p, System.IO.StreamReader inputData)
 {
 }