Example #1
0
 public HResult testa(Request r)
 {
     StreamWriter sw = new StreamWriter(r.res.OutputStream);
     sw.WriteLine("OK");
     sw.Flush();
     return HResult.HRES_RETURN;
 }
Example #2
0
File: FFCM.cs Project: Centny/ffcm
 public virtual HResult OnFfProc(Request r)
 {
     var args = HttpUtility.ParseQueryString(r.req.Url.Query);
     var tid = args.Get("tid");
     var duration_ = args.Get("duration");
     if (String.IsNullOrWhiteSpace(tid) || String.IsNullOrWhiteSpace(duration_))
     {
         r.res.StatusCode = 400;
         r.WriteLine("the tid/duration is required");
         return HResult.HRES_RETURN;
     }
     float duration = 0;
     if (!float.TryParse(duration_, out duration))
     {
         r.res.StatusCode = 400;
         r.WriteLine("the duration must be float");
         return HResult.HRES_RETURN;
     }
     StreamReader reader = new StreamReader(r.req.InputStream);
     String line = null;
     var frame = new Dict();
     while ((line = reader.ReadLine()) != null)
     {
         line = line.Trim();
         if (line.Length < 1)
         {
             continue;
         }
         var kvs = line.Split(new char[] { '=' }, 2);
         var key = kvs[0].Trim();
         if (kvs.Length < 2)
         {
             frame[key] = "";
         }
         else
         {
             frame[key] = kvs[1].Trim();
         }
         if (key != "progress")
         {
             continue;
         }
         var ms = frame.Val<float>("out_time_ms", 0);
         this.DTMC.NotifyProc(tid, ms / duration);
     }
     r.res.StatusCode = 200;
     r.WriteLine("OK");
     r.Flush();
     return HResult.HRES_RETURN;
 }
Example #3
0
File: DTM_C.cs Project: Centny/cswf
 public virtual HResult OnProc(Request r)
 {
     var args = HttpUtility.ParseQueryString(r.req.Url.Query);
     var tid = args.Get("tid");
     var key = this.Cfg.Val("proc_key", "progess");
     var rate_ = args.Get(key);
     if (String.IsNullOrWhiteSpace(tid) || String.IsNullOrWhiteSpace(rate_))
     {
         r.res.StatusCode = 400;
         r.WriteLine("the tid/{0} is required", key);
         return HResult.HRES_RETURN;
     }
     float rate = 0;
     if (float.TryParse(rate_, out rate))
     {
         this.NotifyProc(tid, rate);
         r.res.StatusCode = 200;
         r.WriteLine("OK");
     }
     else
     {
         r.res.StatusCode = 400;
         r.WriteLine("the {0} must be float", key);
     }
     return HResult.HRES_RETURN;
 }
Example #4
0
File: FFCM.cs Project: Centny/ffcm
 public virtual HResult OnStatus(Request r)
 {
     r.res.StatusCode = 200;
     r.res.ContentEncoding = Encoding.UTF8;
     r.res.ContentType = "application/json";
     var data = new Dict();
     var tasks = new Dict();
     tasks.Add("queued", TaskPool.Shared.Queued.Count);
     tasks.Add("running", TaskPool.Shared.Running.Count);
     data.Add("tasks", tasks.data);
     data.Add("word_c", WordCov.Cached.Count);
     r.WriteLine(Json.stringify(data.data));
     r.Flush();
     return HResult.HRES_RETURN;
 }