Beispiel #1
0
 /// <summary>
 /// 增加请求
 /// </summary>
 /// <param name="request"></param>
 internal void QueueCometWaitRequest(CometWaitRequest request)
 {
     lock (this.state)
     {
         waitRequests.Add(request);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 推数据,并做对应的检查
 /// </summary>
 /// <param name="request">Comet等待请求</param>
 /// <param name="timeout">是否超时</param>
 /// <returns></returns>
 private object CheckForServerPushEvent(CometWaitRequest request, bool timeout)
 {
     if (CometHelper.CheckForServerPushEvent != null)
     {
         return(CometHelper.CheckForServerPushEvent(request, timeout));
     }
     return(null);
 }
Beispiel #3
0
 /// <summary>
 /// 删除请求
 /// </summary>
 /// <param name="request"></param>
 internal void DequeueCometWaitRequest(CometWaitRequest request)
 {
     lock (state)
     {
         this.waitRequests.Remove(request);
         CometWaitRequest.RequestCount--;
     }
 }
Beispiel #4
0
        /// <summary>
        /// 添加请求到队列
        /// </summary>
        /// <param name="request"></param>
        internal static void QueueCometWaitRequest(CometWaitRequest request)
        {
            CometWaitThread waitThread;

            lock (state)
            {
                //  else, get the next wait thread
                waitThread = waitThreads[nextWaitThread];
                //  cycle the thread that we want
                nextWaitThread++;
                if (nextWaitThread == maxWaitThreads)
                {
                    nextWaitThread = 0;
                }

                CometWaitRequest.RequestCount++;
            }

            //  queue the wait request
            waitThread.QueueCometWaitRequest(request);
        }
Beispiel #5
0
        /// <summary>
        /// 请求处理完成,返回结果,并置状态
        /// </summary>
        /// <param name="target"></param>
        private void QueueCometWaitRequest_Finished(object target)
        {
            CometWaitRequest request = target as CometWaitRequest;

            request.Result.SetCompleted();
        }