internal override void DoAbortCurrentRequest() { if (cometRequest != null) { cometRequest.Abort(); cometRequest = null; } }
public static CometRequest Invoke(string url, ProcessMessageDelegate ProcessMessage, Action onComplete) { IFrameElement hiddenIFrame = (IFrameElement)Document.CreateElement("IFRAME"); CometRequest cometRequest = new CometRequest(hiddenIFrame); Action notifyComplete = new Action ( delegate() { cometRequest.NotifyComplete(); } ); cometRequest.OnCometRequestComplete = onComplete; Script.Literal("{0}.receive = function(message){{{1}(unescape(message));}};", hiddenIFrame, ProcessMessage); Script.Literal("{0}.notifyComplete = {1};", hiddenIFrame, notifyComplete); hiddenIFrame.Src = url; hiddenIFrame.Style.Visibility = "hidden"; Document.Body.AppendChild(hiddenIFrame); return cometRequest; }
protected override void MakeRequest(string text, Dictionary parameters, int maxNumberOfItemsToGet) { string requestUrl = url + "?text=" + text.Escape() + "&maxNumberOfItemsToGet=" + maxNumberOfItemsToGet; foreach (DictionaryEntry entry in parameters) { requestUrl += "&" + entry.Key.Escape() + "=" + entry.Value.ToString().Escape(); } this.cometRequest = CometProxy.Invoke( requestUrl, delegate(string message) { if (this.OnSuggestionReceived != null) OnSuggestionReceived( (Suggestion[])Script.Eval("(" + message + ")") ); }, delegate() { if (this.OnAllSuggestionsReceived != null) OnAllSuggestionsReceived(); } ); }