Esempio n. 1
0
        public void AbortRequest(string webRequestId, bool fireEvent)
        {
            try {
                UnityWebRequestWrapper unityWebRequestWrapper;
                if (currentWebRequests.TryGetValue(webRequestId, out unityWebRequestWrapper))
                {
                    if (unityWebRequestWrapper != null)
                    {
                        StopTimeoutsAndComplete(unityWebRequestWrapper, webRequestId, false);

                        if ((unityWebRequestWrapper.CurrentUnityWebRequest != null) && (!unityWebRequestWrapper.CurrentUnityWebRequest.isDone))
                        {
                            unityWebRequestWrapper.CurrentUnityWebRequest.Abort();
                            unityWebRequestWrapper.CurrentUnityWebRequest.Dispose();
                        }
                        currentWebRequests.Remove(webRequestId);
                        unityWebRequestWrapper.CurrentRequestState.ResponseCode = 0;
                        unityWebRequestWrapper.CurrentRequestState.URL          = unityWebRequestWrapper.URL;
                        if (fireEvent)
                        {
                            FireEvent("Aborted", true, false, unityWebRequestWrapper.CurrentRequestState, unityWebRequestWrapper.CurrentRequestType, webRequestId);
                            #if (ENABLE_PUBNUB_LOGGING)
                            this.PNLog.WriteToLog(string.Format("BounceRequest: event fired {0}", unityWebRequestWrapper.CurrentRequestState.ToString()), PNLoggingMethod.LevelInfo);
                            #endif
                        }
                        #if (ENABLE_PUBNUB_LOGGING)
                        else
                        {
                            this.PNLog.WriteToLog(string.Format("BounceRequest: event NOT fired {0}", unityWebRequestWrapper.CurrentRequestState.ToString()), PNLoggingMethod.LevelInfo);
                        }
                        #endif
                    }
                }
            } catch (Exception ex) {
                #if (ENABLE_PUBNUB_LOGGING)
                this.PNLog.WriteToLog(string.Format("BounceRequest: Exception: {0}", ex.ToString()), PNLoggingMethod.LevelError);
                #endif
            }
        }
Esempio n. 2
0
        void UpdateLatency(ref SafeDictionary <long, float> dict, long t, ref float f, string name)
        {
            List <long> keys    = new List <long>(dict.Keys);
            float       timeAvg = 0;

            foreach (long key in keys)
            {
                if (key < t)
                {
                    dict.Remove(key);
                }
                else
                {
                    timeAvg += dict[key];
                }
            }
            int count = dict.Count();

            if (count > 0)
            {
                timeAvg /= count;
            }
            f = timeAvg;
        }