/// <summary> /// Public constructor /// </summary> /// <param name="playerKey"></param> /// <param name="playerValue"></param> /// <param name="flags"></param> /// <param name="clientLoginTime"></param> /// <param name="location"></param> public PlayerInstance(string playerKey, string playerValue, int flags, DateTime clientLoginTime, HostInstance location) { PlayerKey = playerKey; PlayerValue = playerValue; Flags = flags; ClientLoginTime = clientLoginTime; HostLoginTime = DateTime.UtcNow; HostLocation = location; //Debug.Log("<PlayerInstance> " + playerName + " Created"); }
/// <summary> /// Remove Host from Collection of Connected HostInstances /// </summary> /// <param name="hostName"></param> /// <param name="hostPassword">Optional</param> /// <param name="forceRemoval">Overrides password check</param> /// <returns></returns> public bool RemoveHost(string hostName, string hostPassword, bool forceRemoval = false) { bool result = false; if (Connected.ContainsKey(hostName)) { _temp = Connected[hostName]; // only get removed if allowed if (forceRemoval || _temp.VerifyPassword(hostPassword)) { result = Connected.Remove(hostName); } if (MasterServer.ViewDebugMessages) { Debug.Log("<Hosts> Host Instance [" + hostName + "] removed successfully."); } } return(result); }
/// <summary> /// Add a player to the Instances collection /// </summary> /// <param name="playerKey"></param> /// <param name="playerValue"></param> /// <param name="flags"></param> /// <param name="clientLoginTime"></param> /// <param name="location"></param> /// <returns></returns> public bool AddPlayer(string playerKey, string playerValue, int flags, DateTime clientLoginTime, HostInstance location) { bool result = false; if (!Instances.ContainsKey(playerKey)) { Instances.Add(playerKey, new PlayerInstance(playerKey, playerValue, flags, clientLoginTime, location)); Players.CurrentPlayerCount++; result = true; if (MasterServer.ViewDebugMessages) { Debug.Log("<Players> AddPlayer [" + playerKey + "] success"); } } else { Debug.LogError("<Players> AddPlayer [" + playerKey + "] duplicate detected. Failure."); } return(result); }