Beispiel #1
0
 protected void AddCometInfo(CometInfo info)
 {
     lock (_cometHandles) {
         List <CometInfo> list;
         if (!_comets.TryGetValue(info.WaitHandle, out list))
         {
             list = new List <CometInfo> ();
             _comets.Add(info.WaitHandle, list);
             _cometHandles.Add(info.WaitHandle);
         }
         list.Add(info);
     }
 }
 public object CometHandler(CometInfo info)
 {
     info.WaitHandle.Close ();
     MergeableFileHeader header = _node.MMLC.GetMergeableFileHeader (_key);
     if (header == null)
         throw new HttpException (HttpStatusCode.NotFound);
     return (header.Content as IMergeableFile).WebUIHelper.ProcessGetRequest
         (_node, info.Request, info.Response, header, _tail);
 }
        object Process_ViewMergeableFilePage(IHttpRequest req, HttpResponseHeader res, Key key, MergeableFileHeader header, string url_tail)
        {
            if (req.HttpMethod == HttpMethod.POST) {
                if (req.QueryData.Count > 0) {
                    return (header.Content as IMergeableFile).WebUIHelper.ProcessPutRequest (_node, req, res, header, url_tail);
                }
                return Process_Post (req, res, header, url_tail);
            }

            if (!_fastView || header == null || header.RecordsetHash.IsZero ()) {
                ManualResetEvent done = new ManualResetEvent (false);
                MergeCometInfo mci = new MergeCometInfo (_node, key, url_tail);
                CometInfo info = new CometInfo (done, req, res, null, DateTime.Now + TimeSpan.FromSeconds (5), mci.CometHandler);
                _node.MMLC.StartMerge (key, delegate (object sender, MergeDoneCallbackArgs args) {
                    if (done.SafeWaitHandle.IsClosed)
                        return;
                    done.Set ();
                }, null);
                return info;
            } else {
                _node.MMLC.StartMerge (header.Key, null, null);
            }

            return (header.Content as IMergeableFile).WebUIHelper.ProcessGetRequest (_node, req, res, header, url_tail);
        }