Ejemplo n.º 1
0
        public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)     //处理函数, inputData就是从客户端读的东西
        {
            Console.WriteLine("POST request: {0}", p.http_url);
            //string data = inputData.ReadToEnd();

            //打印 客服端的数据
            Console.WriteLine("cline data:");
            string op = inputData.ReadLine();

            op.ToLower();
            Console.WriteLine(op);
            string username = inputData.ReadLine();

            Console.WriteLine(username);
            string password = inputData.ReadLine();

            Console.WriteLine(password);
            BookSeat booker = new BookSeat();

            //回复内容
            string res = "";

            if (op == "login")
            {
                res = booker.Login(username, password);
            }
            else if (op == "query")
            {
                string roomID = inputData.ReadLine();
                res = booker.GetSeats(roomID, username, password);
            }
            else if (op == "book")
            {
                string buildingId = inputData.ReadLine();
                string roomId     = inputData.ReadLine();
                string seatId     = inputData.ReadLine();
                string date       = inputData.ReadLine();
                string startTime  = inputData.ReadLine();
                string endTime    = inputData.ReadLine();


                //这里不安全,要改
                booker.buildingId = buildingId;
                booker.roomId     = roomId;
                booker.seatId     = seatId;
                booker.date       = date;
                booker.startTime  = startTime;
                booker.endTime    = endTime;

                res = booker.BookS(username, password); s
            }
            else
            {
                res = "error";
            }


            Console.WriteLine("request data: {0}", res);
            p.writeSuccess();       ///http 头部
            p.outputStream.WriteLine("{0}", res);
        }
Ejemplo n.º 2
0
 public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
Ejemplo n.º 3
0
 public abstract void handlePOSTRequest(HttpProcessor p, string inputData);
Ejemplo n.º 4
0
 public abstract void handleGETRequest(HttpProcessor p);