public Userspace DefineUserspace(string userspaceName, string userspaceDirectory)
        {
            Userspace userspace = null;

            if (!string.IsNullOrWhiteSpace(userspaceName) ^ !string.IsNullOrWhiteSpace(userspaceDirectory))
            {
                if (string.IsNullOrWhiteSpace(userspaceName))
                {
                    userspaceName = Path.GetFileNameWithoutExtension(userspaceDirectory);
                }
                if (string.IsNullOrWhiteSpace(userspaceDirectory))
                {
                    userspaceDirectory = PathBuilder.Combine(_globalContext.UserspacesDirectory, userspaceName);
                }
                userspaceDirectory = _fileSystem.GetFullPath(userspaceDirectory);

                var profiles = new[]
                {
                    PathBuilder.Complete(_globalContext.UserspacesDirectory, Files.AllUserspacesPs1),
                    PathBuilder.Complete(userspaceDirectory, Files.UserspacePs1)
                };

                var marker = PathBuilder.Complete(userspaceDirectory, Files.UserspacePs1);

                userspace = new Userspace(userspaceDirectory, marker, profiles);
            }

            return(userspace);
        }
Example #2
0
        private void FocusedWorld(World world)
        {
            if (currentWorld != null && !is_in_VR_mode)
            {
                try
                {
                    if (currentWorld.IsAuthority)
                    {
                        Userspace.LeaveSession(currentWorld);
                    }
                    else
                    {
                        Userspace.EndSession(currentWorld);
                    }
                } catch (Exception e)
                {
                    UniLog.Log("Exception when leaving/ending session: " + e.Message);
                }
            }
            bool is_there_metagen_in_world = false;

            foreach (var item in metagens)
            {
                try
                {
                    MetaGen metagen = item.Value;
                    metagen.StopPlaying();
                    metagen.StopRecording();
                    //metagen.Destroy();
                    if (metagen.World == world)
                    {
                        is_there_metagen_in_world = true;
                    }
                } catch (Exception e)
                {
                    UniLog.Log("owo Exception when stopping the metagens when focusing a new world");
                    UniLog.Log("This could be because someone invited the bot while it was playing");
                }
            }
            current_session_id = world.SessionId;
            currentWorld       = world;
            if (!is_there_metagen_in_world)
            {
                AddWorld(world);
            }
        }
Example #3
0
        private void processInvite(Message msg)
        {
            //if (msg.SenderId == "U-guillefix") return;
            //string userName = this.Engine.Cloud.Friends.FindFriend(f => f.FriendUserId == msg.SenderId).FriendUsername;
            //if (userName == "badhaloninja" || userName == "marsmaantje" || userName == "oXoMaStErSoXo") return;
            SessionInfo  sessionInfo  = msg.ExtractContent <SessionInfo>();
            WorldManager worldManager = FrooxEngine.Engine.Current.WorldManager;
            List <Uri>   sessions     = sessionInfo.GetSessionURLs();

            if (current_metagen == null ? true : !current_metagen.recording)
            {
                World world = worldManager.JoinSession(sessions);
                StartTask(async() => await Userspace.FocusWhenReady(world));
            }
            else
            {
                MessageManager.UserMessages userMessages = this.Engine.Cloud.Messages.GetUserMessages(msg.SenderId);
                //CloudX.Shared.Message textMessage = userMessages.CreateTextMessage("Busy recording somewhere else. Try again in a bit!");
                userMessages.SendTextMessage("Sorry. Busy recording somewhere else. Try again in a bit!");
            }
        }
        public Userspace CreateUserspace(Userspace userspace)
        {
            if (userspace != null)
            {
                _fileSystem.DirectoryCreate(userspace.Directory);

                var userspaceProfilePath = _profileRepository.CurrentUserspace(userspace.Directory);
                _resourceRepository.CreateResource(userspaceProfilePath, Files.UserspacePs1);

                var allUserspacesProfilePath = _profileRepository.AllUserspaces();
                _resourceRepository.CreateResource(allUserspacesProfilePath, Files.AllUserspacesPs1);

                var allWorkspacesProfile = _profileRepository.AllWorkspaces();
                _resourceRepository.CreateResource(allWorkspacesProfile, Files.AllWorkspacesPs1);

                var workspacesProfilePath = _profileRepository.Workspaces(userspace.Directory);
                _resourceRepository.CreateResource(workspacesProfilePath, Files.WorkspacesPs1);


                var configDirectory = PathBuilder.Combine(userspace.Directory, Directories.Config, Directories.Workbench);
                _fileSystem.DirectoryCreate(configDirectory);

                var discoveryConfigPath = PathBuilder.Combine(configDirectory, Files.DiscoveryJson);
                _resourceRepository.CreateResource(discoveryConfigPath, Files.DiscoveryUSJson);

                var shortcutConfigPath = PathBuilder.Combine(configDirectory, Files.ShortcutJson);
                _resourceRepository.CreateResource(shortcutConfigPath, Files.ShortcutUSJson);

                var applicationConfigPath = PathBuilder.Combine(configDirectory, Files.ApplicationJson);
                _resourceRepository.CreateResource(applicationConfigPath, Files.ApplicationUSJson);

                var backupConfigPath = PathBuilder.Combine(configDirectory, Files.BackupJson);
                _resourceRepository.CreateResource(backupConfigPath, Files.BackupUSJson);
            }

            return(userspace);
        }