public override void OnDisabled() { base.OnDisabled(); ServerLocks.Clear(); LockAcquireEvents.Clear(); LockReleaseEvents.Clear(); }
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; } }
/// <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 }); } }
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); } }
/// <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); } }
public string[] GetLocksWithPrefix(string lockPrefix) { return(ServerLocks.Where(l => l.Key.StartsWith(lockPrefix)).Select(l => l.Key).ToArray()); }
public string[] GetPlayerLocksPrefix(string playerName, string lockPrefix) { return(ServerLocks.Where(l => l.Value == playerName && l.Key.StartsWith(lockPrefix)).Select(l => l.Key).ToArray()); }
public string[] GetPlayerLocks(string playerName) { return(ServerLocks.Where(l => l.Value == playerName).Select(l => l.Key).ToArray()); }
public string LockOwner(string lockName) { return(ServerLocks.ContainsKey(lockName) ? ServerLocks[lockName] : "unknown player"); }
public bool LockExists(string lockName) { return(ServerLocks.ContainsKey(lockName)); }
public bool SpectatorLockExists(Guid vesselId) { return(ServerLocks.Any(l => l.Key.EndsWith(vesselId.ToString()) && l.Key.StartsWith("spectator-"))); }
public bool LockWithPrefixExists(string lockPrefix) { return(ServerLocks.Any(l => l.Key.StartsWith(lockPrefix))); }
public bool LockIsOurs(string lockName) { return(ServerLocks.ContainsKey(lockName) && (ServerLocks[lockName] == SettingsSystem.CurrentSettings.PlayerName)); }
public string[] GetOwnedLocksPrefix(string lockPrefix) { return(ServerLocks.Where(l => l.Value == SettingsSystem.CurrentSettings.PlayerName && l.Key.StartsWith(lockPrefix)) .Select(l => l.Key).ToArray()); }