Exemplo n.º 1
0
        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (StreamReader rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            using (var db = new Database())
            {
                var acc = db.Verify(query["guid"], query["password"]);
                byte[] status;
                if (acc == null)
                    status = Encoding.UTF8.GetBytes("<Error>Bad login</Error>");
                else
                {
                    try
                    {
                        status = Encoding.UTF8.GetBytes(db.HTTPGetGuildMembers(Convert.ToInt32(query["num"]), Convert.ToInt32(query["offset"]), acc));
                    }
                    catch
                    {
                        status = Encoding.UTF8.GetBytes("<Error>Guild member error</Error>");
                    }
                }
                context.Response.OutputStream.Write(status, 0, status.Length);
                context.Response.Close();
            }
        }
Exemplo n.º 2
0
 protected override void HandleRequest()
 {
     using (var db = new Database())
     {
         var acc = db.Verify(Query["guid"], Query["password"]);
         byte[] status;
         if (acc == null)
             status = Encoding.UTF8.GetBytes("<Error>Bad login</Error>");
         else
         {
             try
             {
                 status = Encoding.UTF8.GetBytes(db.HTTPGetGuildMembers(Convert.ToInt32(Query["num"]), Convert.ToInt32(Query["offset"]), acc));
             }
             catch
             {
                 status = Encoding.UTF8.GetBytes("<Error>Guild member error</Error>");
             }
         }
         Context.Response.OutputStream.Write(status, 0, status.Length);
         Context.Response.Close();
     }
 }