Ejemplo n.º 1
0
        public void DownloadAndExtractPackage(UFramePackageDescriptor package, UFramePackageRevisionDescriptor revision)
        {
            GlobalProgressMessage = string.Format("Downloading {0} {1}...", package.Title, revision.VersionTag);

            WWW    req      = null;
            string dataPath = null;

            byte[] bytes = null;

            var d = ThreadingUtils.WaitOnMainThread(() =>
            {
                //Pre
                if (req == null)
                {
                    dataPath = Application.dataPath;
                    //var snapshotUri = command.RevisionDescriptor.SnapshotUri;
                    req = new WWW(revision.SnapshotUri);
                }

                if (req.isDone)
                {
                    //Post
                    bytes = req.bytes;
                    //GlobalProgressMessage = string.Format("Extracting {0} {1}...", command.PackageDescriptor.Title, command.RevisionDescriptor.VersionTag);
                    return(true);
                }

                return(false);
            });

            while (!d.Done)
            {
                Thread.Sleep(100);
            }

            GlobalProgressMessage = string.Format("Extracting {0} {1}...", package.Title, revision.VersionTag);

            var stream       = new MemoryStream(bytes);
            var packagesPath = Path.Combine(dataPath, "uFramePackages");

            EnsurePath(packagesPath);

            var packagePath = Path.Combine(packagesPath, package.Id);

            EnsurePath(packagePath);
            ExtractZipFile(stream, packagePath);
        }
Ejemplo n.º 2
0
        public void Execute(PingServerCommand command)
        {
            WWW      ping    = null;
            DateTime timeOut = DateTime.Now.AddSeconds(15);

            GlobalProgressMessage = "Contacting Koinonia Servers....";

            var d = ThreadingUtils.WaitOnMainThread(() =>
            {
                ping = ping ?? new WWW(command.Server);
                return(ping.isDone);
            });

            while (!d.Done)
            {
                if (DateTime.Now > timeOut) //time outs
                {
                    ThreadingUtils.DispatchOnMainThread(() =>
                    {
                        IsRemoteServerAvailable = string.IsNullOrEmpty(ping.error);
                        GlobalProgressMessage   = null;
                        ping.Dispose();
                    });
                    return;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }

            ThreadingUtils.DispatchOnMainThread(() =>
            {
                IsRemoteServerAvailable = string.IsNullOrEmpty(ping.error);
                GlobalProgressMessage   = null;
                ping.Dispose();
            });
        }