Пример #1
0
        public FileUploader(
            string uploadId,
            string localPath,
            string serverUrl,
            string sessionId,
            int timeout,
            int timeoutThreshold,
            BrainCloudClient client,
            string peerCode = "")
        {
            _client = client;

#if UNITY_WEBPLAYER || UNITY_WEBGL
            throw new Exception("File upload API is not supported on Web builds");
#else
            UploadId   = uploadId;
            _localPath = localPath;
            _serverUrl = serverUrl;
            _sessionId = sessionId;
            _peerCode  = peerCode;

            _timeout          = timeout;
            _timeoutThreshold = timeoutThreshold;

            if (!File.Exists(localPath))
            {
                ThrowError(ReasonCodes.CLIENT_UPLOAD_FILE_UNKNOWN, "File at" + localPath + " does not exist");
                return;
            }

            FileInfo info = new FileInfo(localPath);
            _fileName            = info.Name;
            TotalBytesToTransfer = info.Length;

            Status = FileUploaderStatus.Pending;
#endif
        }
Пример #2
0
        private IEnumerator WaitForReturn(string[] uploadIds, int cancelTime = -1)
        {
            int  count = 0;
            bool sw    = true;

            Debug.Log("Waiting for file to upload...");
            BrainCloudClient client = _tc.bcWrapper.Client;

            client.Update();
            while (_returnCount < uploadIds.Length && count < 1000 * 30)
            {
                for (int i = 0; i < uploadIds.Length; i++)
                {
                    double progress = client.FileService.GetUploadProgress(uploadIds[i]);

                    if (progress > -1 && sw)
                    {
                        string logStr = "File " + (i + 1) + " Progress: " +
                                        progress + " | " +
                                        client.FileService.GetUploadBytesTransferred(uploadIds[i]) + "/" +
                                        client.FileService.GetUploadTotalBytesToTransfer(uploadIds[i]);
                        Debug.Log(logStr);
                    }

                    if (cancelTime > 0 && progress > 0.05)
                    {
                        client.FileService.CancelUpload(uploadIds[i]);
                    }
                }
                client.Update();
                sw = !sw;

                yield return(new WaitForFixedUpdate());

                count += 150;
            }
        }
Пример #3
0
        private void WaitForReturn(string[] uploadIds, int cancelTime = -1)
        {
            int  count = 0;
            bool sw    = true;

            BrainCloudClient client = _bc.Client;

            client.Update();
            while (_returnCount < uploadIds.Length && count < 1000 * 30)
            {
                for (int i = 0; i < uploadIds.Length; i++)
                {
                    double progress = client.FileService.GetUploadProgress(uploadIds[i]);

                    if (progress > -1 && sw)
                    {
                        string logStr = "File " + (i + 1) + " Progress: " +
                                        progress + " | " +
                                        client.FileService.GetUploadBytesTransferred(uploadIds[i]) + "/" +
                                        client.FileService.GetUploadTotalBytesToTransfer(uploadIds[i]);
                        Console.WriteLine(logStr);
                    }

                    if (cancelTime > 0 && progress > 0.05)
                    {
                        client.FileService.CancelUpload(uploadIds[i]);
                    }
                }

                client.Update();
                sw = !sw;

                Thread.Sleep(150);
                count += 150;
            }
        }
Пример #4
0
        public void TestMessageCache()
        {
            try
            {
                BrainCloudClient.Get().Initialize(ServerUrl + "unitTestFail", Secret, AppId, Version);
                BrainCloudClient.Get().EnableNetworkErrorMessageCaching(true);
                BrainCloudClient.Get().EnableLogging(true);
                BrainCloudClient.Get().SetPacketTimeouts(new List <int> {
                    1, 1, 1
                });

                DateTime   timeStart = DateTime.Now;
                TestResult tr        = new TestResult();
                tr.SetTimeToWaitSecs(30);
                BrainCloudClient.Get().RegisterNetworkErrorCallback(tr.NetworkError);
                BrainCloudClient.Get().AuthenticationService.AuthenticateUniversal("abc", "abc", true, tr.ApiSuccess, tr.ApiError);
                tr.RunExpectFail(StatusCodes.CLIENT_NETWORK_ERROR, ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT);

                BrainCloudClient.Get().RetryCachedMessages();
                tr.Reset();
                tr.RunExpectFail(StatusCodes.CLIENT_NETWORK_ERROR, ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT);

                BrainCloudClient.Get().FlushCachedMessages(true);
                // unable to catch the api callback in this case using tr...

                //tr.Reset();
                //tr.RunExpectFail(StatusCodes.CLIENT_NETWORK_ERROR, ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT);
            }
            finally
            {
                // reset to defaults
                BrainCloudClient.Get().SetPacketTimeoutsToDefault();
                BrainCloudClient.Get().EnableNetworkErrorMessageCaching(false);
                BrainCloudClient.Get().DeregisterNetworkErrorCallback();
            }
        }
Пример #5
0
 public BrainCloudWrapper()
 {
     m_client = new BrainCloudClient();
 }
Пример #6
0
 void Button_Init(object sender, System.EventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("PRESSED INIT");
     InitWrapper();
     client = wrapper.Client;
 }
 public BrainCloudWrapper()
 {
     m_client = BrainCloudClient.Get();
 }
Пример #8
0
 /// <summary>
 ///
 /// </summary>
 public RTTComms(BrainCloudClient in_client)
 {
     m_clientRef = in_client;
 }
Пример #9
0
 /// <summary>
 /// Create the brainCloud Wrapper, which has utility helpers for using the brainCloud API
 /// Can't set the wrapperName on construction? use the WrapperName property instead
 /// </summary>
 /// <param name="wrapperName">string value used to differentiate saved wrapper data</param>
 public BrainCloudWrapper(string wrapperName)
 {
     Client      = new BrainCloudClient();
     WrapperName = wrapperName;
 }
Пример #10
0
 /// <summary>
 /// Create the brainCloud Wrapper, which has utility helpers for using the brainCloud API
 /// </summary>
 /// <param name="client">set wrapper with a specfic brainCloud client</param>
 private BrainCloudWrapper(BrainCloudClient client)
 {
     Client = client;
 }