示例#1
0
        public bool LongPollCheck(EventPollNotify poller, ref long id, out bool isError)
        {
            HttpServer.HttpInput input = String.Equals(Request.Method, "POST", StringComparison.OrdinalIgnoreCase) ? Request.Form : Request.QueryString;
            if (Library.Utility.Utility.ParseBool(input["longpoll"].Value, false))
            {
                long lastEventId;
                if (!long.TryParse(input["lasteventid"].Value, out lastEventId))
                {
                    ReportClientError("When activating long poll, the request must include the last event id", System.Net.HttpStatusCode.BadRequest);
                    isError = true;
                    return(false);
                }

                TimeSpan ts;
                try { ts = Library.Utility.Timeparser.ParseTimeSpan(input["duration"].Value); }
                catch (Exception ex)
                {
                    ReportClientError("Invalid duration: " + ex.Message, System.Net.HttpStatusCode.BadRequest);
                    isError = true;
                    return(false);
                }

                if (ts <= TimeSpan.FromSeconds(10) || ts.TotalMilliseconds > int.MaxValue)
                {
                    ReportClientError("Invalid duration, must be at least 10 seconds, and less than " + int.MaxValue + " milliseconds", System.Net.HttpStatusCode.BadRequest);
                    isError = true;
                    return(false);
                }

                isError = false;
                id      = poller.Wait(lastEventId, (int)ts.TotalMilliseconds);
                return(true);
            }

            isError = false;
            return(false);
        }
示例#2
0
 public HttpServer.Sessions.IHttpSession Session { get; private set; }
示例#3
0
 if (BodyWriter != null)
 {
     var bw = BodyWriter;
     BodyWriter = null;