コード例 #1
0
 public override void OnDisabled()
 {
     base.OnDisabled();
     ServerLocks.Clear();
     LockAcquireEvents.Clear();
     LockReleaseEvents.Clear();
 }
コード例 #2
0
        static void FillRepositoryLocks(
            WorkspaceInfo wkInfo,
            RepositorySpec repSpec,
            List <WorkspaceTreeNode> candidates,
            Dictionary <string, Dictionary <Guid, LockInfo> > locksByItemByServer,
            Dictionary <WorkspaceTreeNode, LockInfo> locks)
        {
            if (candidates.Count == 0)
            {
                return;
            }

            LockRule lockRule = ServerLocks.GetLockRule(repSpec);

            if (lockRule == null)
            {
                return;
            }

            candidates = GetLockableCandidates(candidates, lockRule);

            if (candidates.Count == 0)
            {
                return;
            }

            string lockServer = string.IsNullOrEmpty(lockRule.LockServer) ?
                                repSpec.Server : lockRule.LockServer;

            Dictionary <Guid, LockInfo> serverlocksByItem =
                ServerLocks.GetServerLocksByItem(
                    lockServer, locksByItemByServer);

            if (serverlocksByItem == null || serverlocksByItem.Count == 0)
            {
                return;
            }

            IList <Guid> candidatesGuids = GetCandidatesGuids(
                wkInfo, repSpec, candidates);

            for (int index = 0; index < candidates.Count; index++)
            {
                LockInfo serverLock;
                if (!serverlocksByItem.TryGetValue(
                        candidatesGuids[index], out serverLock))
                {
                    continue;
                }

                locks[candidates[index]] = serverLock;
            }
        }
コード例 #3
0
 /// <summary>
 /// Release the specified lock
 /// </summary>
 public void ReleaseLock(string lockName)
 {
     if (LockIsOurs(lockName))
     {
         ServerLocks.Remove(lockName);
         MessageSender.SendMessage(new LockReleaseMsgData
         {
             PlayerName = SettingsSystem.CurrentSettings.PlayerName,
             LockName   = lockName
         });
     }
 }
コード例 #4
0
        public void ReleaseLocksWithPrefix(string prefix)
        {
            var removeList = ServerLocks
                             .Where(l => l.Key.StartsWith(prefix) && (l.Value == SettingsSystem.CurrentSettings.PlayerName))
                             .Select(l => l.Key)
                             .ToArray();

            foreach (var removeValue in removeList)
            {
                ReleaseLock(removeValue);
                ServerLocks.Remove(removeValue);
                FireReleaseEvent(SettingsSystem.CurrentSettings.PlayerName, removeValue);
            }
        }
コード例 #5
0
        /// <summary>
        /// Release the specified control lock excepts the ones you pass.
        /// You must send the full control lock name, not the prefix
        /// </summary>
        public void ReleaseControlLocksExcept(params string[] lockNames)
        {
            var removeList = ServerLocks
                             .Where(l => !lockNames.Contains(l.Key) && l.Key.StartsWith("control-") && (l.Value == SettingsSystem.CurrentSettings.PlayerName))
                             .Select(l => l.Key)
                             .ToArray();

            foreach (var removeValue in removeList)
            {
                ReleaseLock(removeValue);
                ServerLocks.Remove(removeValue);
                FireReleaseEvent(SettingsSystem.CurrentSettings.PlayerName, removeValue);
            }
        }
コード例 #6
0
 public string[] GetLocksWithPrefix(string lockPrefix)
 {
     return(ServerLocks.Where(l => l.Key.StartsWith(lockPrefix)).Select(l => l.Key).ToArray());
 }
コード例 #7
0
 public string[] GetPlayerLocksPrefix(string playerName, string lockPrefix)
 {
     return(ServerLocks.Where(l => l.Value == playerName && l.Key.StartsWith(lockPrefix)).Select(l => l.Key).ToArray());
 }
コード例 #8
0
 public string[] GetPlayerLocks(string playerName)
 {
     return(ServerLocks.Where(l => l.Value == playerName).Select(l => l.Key).ToArray());
 }
コード例 #9
0
 public string LockOwner(string lockName)
 {
     return(ServerLocks.ContainsKey(lockName) ? ServerLocks[lockName] : "unknown player");
 }
コード例 #10
0
 public bool LockExists(string lockName)
 {
     return(ServerLocks.ContainsKey(lockName));
 }
コード例 #11
0
 public bool SpectatorLockExists(Guid vesselId)
 {
     return(ServerLocks.Any(l => l.Key.EndsWith(vesselId.ToString()) && l.Key.StartsWith("spectator-")));
 }
コード例 #12
0
 public bool LockWithPrefixExists(string lockPrefix)
 {
     return(ServerLocks.Any(l => l.Key.StartsWith(lockPrefix)));
 }
コード例 #13
0
 public bool LockIsOurs(string lockName)
 {
     return(ServerLocks.ContainsKey(lockName) && (ServerLocks[lockName] == SettingsSystem.CurrentSettings.PlayerName));
 }
コード例 #14
0
 public string[] GetOwnedLocksPrefix(string lockPrefix)
 {
     return(ServerLocks.Where(l => l.Value == SettingsSystem.CurrentSettings.PlayerName && l.Key.StartsWith(lockPrefix))
            .Select(l => l.Key).ToArray());
 }