示例#1
0
 /// <summary>
 /// Sends a request
 /// </summary>
 /// <param name="request"></param>
 /// <param name="responders"></param>
 /// <returns></returns>
 public AsyncToken Send(WebRequest request, params Responder[] responders)
 {
     AsyncToken token = Send(request);
     HandleResponders(responders, token);
     return token;
 }
示例#2
0
        ///<summary>
        /// Sends a request
        ///</summary>
        ///<param name="request"></param>
        ///<param name="resultHandlers"></param>
        ///<returns></returns>
        public AsyncToken Send(WebRequest request, params ResultHandler[] resultHandlers)
        {
            List<Responder> responders = new List<Responder>();

            foreach (ResultHandler resultHandler in resultHandlers)
            {
                responders.Add(new Responder(resultHandler));
            }

            return Send(request, responders.ToArray());
        }
示例#3
0
        /// <summary>
        /// Sends a request
        /// This method is always called when calling any of Send overrides
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public AsyncToken Send(WebRequest request)
        {
            if (string.IsNullOrEmpty(request.Url))
                throw new Exception("URL not set");

            if (CacheBuster)
                request.CacheBuster = true;

            #region Handling relative ULRs

            string url = request.Url;

            if (url.StartsWith("~"))
            {
                url = Url + request.Url.TrimStart('~');
            }

            request.Url = url;

            #endregion

            #if DEBUG
            if (DebugMode || LogCalls)
                Debug.Log(string.Format(@"* {0}
            {1}", this, request));
            #endif

            // create token
            AsyncToken token = new AsyncToken {Request = request, Timeout = Timeout};

            // add it to queue
            _queued.Add(token);

            if (!SystemManager.Instance.UpdateSignal.HasSlot(UpdateSlot))
            {
            #if DEBUG
                if (DebugMode)
                {
                    Debug.Log("Connecting to UpdateSignal");
                }
            #endif
                SystemManager.Instance.UpdateSignal.Connect(UpdateSlot);
            }

            IsWorking = true;

            DispatchStatusEvent();

            // return it to caller
            return token;
        }