Esempio n. 1
0
 public CometAsyncResult(ChatRequest chatRequest, HttpContext context, AsyncCallback callBack, object asyncState)
 {
     this.Request = chatRequest;
     this.Response = new ChatResponse();
     this.BeginTime = DateTime.Now;
     this.Context = context;
     this.AsyncState = asyncState;
     this.CallBack = callBack;
 }
Esempio n. 2
0
 public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
 {
     ChatRequest request = new ChatRequest();
     request.Identity = 1;
     int lastId =0;
     if (!string.IsNullOrEmpty(context.Request.QueryString["lastid"]))
     {
         int.TryParse(context.Request.QueryString["lastid"],out lastId);
     }
     request.lastId = lastId;
     //异步请求将请求放入自定义线程池内,由消息抽发或者定时轮询处理
     //Chunked很难处理浏览器未加载完问题,暂时不做,有消息即返回
     CometAsyncResult result = new CometAsyncResult(request,context, cb, extraData);
     result.HandleCometRequest();
     return result;
 }