예제 #1
0
        private IEnumerator PullMessages()
        {
            string url = this.sessionUrl + this.sessionTimeTag;
            uint   num = this.pullRequestId;
            WWW    wWW = new WWW(url);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (WWWManager.Remove(wWW) && num == this.pullRequestId)
            {
                if (wWW.error == null)
                {
                    this.OnPollFinished(wWW.text);
                }
                else if (this.sessionState == ChatSessionState.Connected)
                {
                    this.OnPollFinished(null);
                }
                else
                {
                    this.ReconnectSession();
                    Service.Get <StaRTSLogger>().Warn("Unable to pull chat messages. Reconnecting: " + wWW.error);
                }
            }
            wWW.Dispose();
            yield break;
        }
예제 #2
0
        private IEnumerator Publish(string url)
        {
            WWW wWW = new WWW(url);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (WWWManager.Remove(wWW))
            {
                if (wWW.error == null)
                {
                    this.wwwRetryCount = 0;
                }
                else
                {
                    int num = this.wwwRetryCount + 1;
                    this.wwwRetryCount = num;
                    if (num < this.wwwMaxRetry)
                    {
                        Service.Get <Engine>().StartCoroutine(this.Publish(url));
                        Service.Get <StaRTSLogger>().Warn("Unable to publish chat message. Retrying: " + wWW.error);
                    }
                    else
                    {
                        Service.Get <StaRTSLogger>().Warn("Unable to publish chat: " + wWW.error);
                    }
                }
            }
            wWW.Dispose();
            yield break;
        }
예제 #3
0
        private IEnumerator DownloadProfileImageCoroutine(string url, OnGetProfilePicture callback, object cookie)
        {
            WWW wWW = new WWW(url);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (WWWManager.Remove(wWW))
            {
                string error = wWW.error;
                if (string.IsNullOrEmpty(error))
                {
                    callback(wWW.texture, cookie);
                }
                else
                {
                    Service.Logger.ErrorFormat("Error fetching picture at {0}", new object[]
                    {
                        url
                    });
                }
                wWW.Dispose();
            }
            yield break;
        }
예제 #4
0
        private IEnumerator LoadImage(string url, ThumbnailManager.ImageLoadCompleteDelegate onLoadComplete)
        {
            WWW wWW = new WWW(url);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (!WWWManager.Remove(wWW))
            {
                yield break;
            }
            string    error   = wWW.error;
            Texture2D texture = wWW.texture;

            if (string.IsNullOrEmpty(error))
            {
                this.Store(url, texture);
                onLoadComplete(texture);
                this.Remove(url);
            }
            else
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Error fetching thumbnail at {0}", new object[]
                {
                    url
                });
                onLoadComplete(null);
            }
            wWW.Dispose();
            yield break;
        }
예제 #5
0
        private IEnumerator Download(string url)
        {
            WWW wWW = new WWW(url);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (WWWManager.Remove(wWW))
            {
                if (!string.IsNullOrEmpty(wWW.error) && wWW.error.StartsWith("Could not resolve host"))
                {
                    Lang lang = Service.Lang;
                    AlertScreen.ShowModal(true, lang.Get("NO_INTERNET_TITLE", new object[0]), lang.Get("NO_INTERNET", new object[0]), null, null);
                }
                wWW.Dispose();
            }
            yield break;
        }
예제 #6
0
        private IEnumerator ConnectToChannel()
        {
            WWW wWW = new WWW(this.channelUrl);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (WWWManager.Remove(wWW) && this.sessionState == ChatSessionState.Connecting)
            {
                string error = wWW.error;
                string text  = wWW.text;
                if (error == null)
                {
                    this.wwwRetryCount = 0;
                    this.sessionState  = ChatSessionState.Connected;
                    this.sessionUrl    = ChatSessionUtils.GetSessionUrlFromChannelResponse(text);
                    if (!string.IsNullOrEmpty(this.sessionUrl))
                    {
                        this.Poll();
                    }
                    else
                    {
                        Service.Get <StaRTSLogger>().Error("Invalid chat channel response: " + text);
                    }
                }
                else
                {
                    int num = this.wwwRetryCount + 1;
                    this.wwwRetryCount = num;
                    if (num < this.wwwMaxRetry)
                    {
                        this.ReconnectSession();
                        Service.Get <StaRTSLogger>().Warn("Unable to start chat session. Retrying: " + error);
                    }
                    else
                    {
                        this.sessionState = ChatSessionState.Disconnected;
                        Service.Get <StaRTSLogger>().Warn("Unable to start chat session: " + error);
                    }
                }
            }
            wWW.Dispose();
            yield break;
        }
        private IEnumerator RequestManifestFile()
        {
            WWW wWW = new WWW(this.manifestUrl);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (!WWWManager.Remove(wWW))
            {
                yield break;
            }
            if (wWW.error != null)
            {
                this.logger.ErrorFormat("Unable to request manifest file [{0}] on attempt #{1} with the following error: {2}", new object[]
                {
                    this.manifestUrl,
                    this.loadAttempts,
                    wWW.error
                });
                this.RetryRequest();
            }
            else if (wWW.isDone)
            {
                if (wWW.text != "")
                {
                    this.PrepareManifest(wWW.text);
                }
                else
                {
                    this.logger.ErrorFormat("Manifest request attempt #{0} yielded an empty manifest.", new object[]
                    {
                        this.loadAttempts
                    });
                    this.RetryRequest();
                }
            }
            wWW.Dispose();
            yield break;
        }
예제 #8
0
        private IEnumerator Query(string url, VideoDataManager.QueryCompleteDelegate onQueryComplete, object callback, object data)
        {
            WWW wWW = new WWW(url);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (!WWWManager.Remove(wWW))
            {
                yield break;
            }
            string error = wWW.error;

            if (!string.IsNullOrEmpty(error))
            {
                onQueryComplete(null, callback, data);
            }
            else
            {
                onQueryComplete(wWW.text, callback, data);
            }
            wWW.Dispose();
            yield break;
        }
예제 #9
0
        private IEnumerator Call(WWWForm form, Batch batch)
        {
            this.qccCount = 0u;
            WWW wWW = new WWW(this.url, form.data, this.headers);

            WWWManager.Add(wWW);
            yield return(wWW);

            if (WWWManager.Remove(wWW))
            {
                uint serverTime = Service.ServerAPI.ServerTime;
                if (string.IsNullOrEmpty(wWW.error))
                {
                    string name = "Received batch response";
                    Service.AssetManager.Profiler.RecordFetchEvent(name, wWW.bytesDownloaded, true, true);
                    object   obj      = new JsonParser(wWW.text).Parse();
                    Response response = new Response();
                    response.FromObject(obj);
                    bool  flag   = this.responseHandler.MatchProtocolVersion(response.ProtocolVersion);
                    Batch batch2 = null;
                    for (int i = 0; i < batch.Commands.Count; i++)
                    {
                        ICommand command = batch.Commands[i];
                        Data     data    = response.DataList[i];
                        if (data.RequestId != command.Id)
                        {
                            this.logger.Error("RequestId Mismatch in Dispatcher!");
                        }
                        bool             success          = this.SuccessStatuses.Contains(data.Status);
                        OnCompleteAction onCompleteAction = command.OnComplete(data, success);
                        if (data.Messages != null)
                        {
                            this.responseHandler.SendMessages(data.Messages);
                        }
                        if (this.qcc.Enabled && this.qcc.StatusWhitelist.Contains(data.Status))
                        {
                            this.qcc.CorrectBatch(batch, response.DataList, i, new QuietCorrectionController.HandleBatch(this.ReCall));
                            wWW.Dispose();
                            if (batch.Sync)
                            {
                                this.syncDispatchLock = false;
                            }
                            goto IL_4DF;
                        }
                        if (onCompleteAction == OnCompleteAction.Desync)
                        {
                            this.responseHandler.Desync(DesyncType.CriticalCommandFail, data.Status);
                            wWW.Dispose();
                            goto IL_4DF;
                        }
                        if (onCompleteAction == OnCompleteAction.Retry && flag)
                        {
                            command.Tries += 1u;
                            if (command.Tries > 3u)
                            {
                                Service.Logger.Error("Command Desync. " + this.CreateCommandErrorString(command, serverTime));
                                this.responseHandler.Desync(DesyncType.CommandMaxRetry, data.Status);
                                wWW.Dispose();
                                goto IL_4DF;
                            }
                            if (batch2 == null)
                            {
                                batch2      = new Batch();
                                batch2.Sync = batch.Sync;
                            }
                            Service.Logger.Warn("Command Resend. " + this.CreateCommandErrorString(command, serverTime));
                            command.SetTime(serverTime);
                            batch2.Commands.Add(command);
                        }
                    }
                    if (batch2 != null)
                    {
                        this.Exec(batch2);
                        wWW.Dispose();
                        goto IL_4DF;
                    }
                    if (batch.Sync)
                    {
                        this.syncDispatchLock           = false;
                        this.lastSuccessfulSyncReqestId = this.FindMinMaxCommandId(batch, false);
                    }
                }
                else
                {
                    batch.Tries += 1u;
                    if (batch.Tries > 3u)
                    {
                        Match match  = Regex.Match(wWW.error, "\\d+");
                        uint  status = (!match.Success) ? 0u : Convert.ToUInt32(match.Value);
                        Service.Logger.Error("Batch Desync. " + this.CreateBatchErrorString(batch, wWW, serverTime));
                        this.responseHandler.Desync(DesyncType.BatchMaxRetry, status);
                        wWW.Dispose();
                        goto IL_4DF;
                    }
                    Service.Logger.Warn("Batch WWW Error. " + this.CreateBatchErrorString(batch, wWW, serverTime));
                    this.Exec(batch);
                }
                wWW.Dispose();
            }
IL_4DF:
            yield break;
        }