public void AddRoomProperties(KeyValuePair <object, object> roomProperties, bool reqSyncData = true) { if (SalinTokens.ValidateTokenUserToken() == false) { return; } if (RoomProperties.ContainsKey(roomProperties.Key) == true) { Debug.Log("The key is already contains RoomProperties. Update the value"); RoomProperties[roomProperties.Key] = roomProperties.Value; } else { RoomProperties.Add(roomProperties.Key, roomProperties.Value); } #if PHOTON_UNITY_NETWORKING if (reqSyncData == true) { PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable() { { roomProperties.Key, roomProperties.Value } }); } #endif }
public void RemoveRoomProperties(string roomPropertiesKey, bool reqSyncData = true) { if (SalinTokens.ValidateTokenUserToken() == false) { return; } if (RoomProperties.ContainsKey(roomPropertiesKey) == false) { Debug.Log("The key is not in the RoomProperties."); return; } RoomProperties.Remove(roomPropertiesKey); #if PHOTON_UNITY_NETWORKING if (reqSyncData == true) { PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable() { { roomPropertiesKey, null } }); } #endif }
public RoomInfo(Photon.Realtime.RoomInfo roomInfo) { RemoveFromList = roomInfo.RemovedFromList; RoomName = roomInfo.Name; IsOpen = roomInfo.IsOpen; PlayerCount = roomInfo.PlayerCount; MaxPlayerCount = roomInfo.MaxPlayers; RoomProperties = (Dictionary <object, object>)roomInfo.CustomProperties.Clone(); if (RoomProperties.ContainsKey(RoomOptionKey.Password)) { Password = RoomProperties[RoomOptionKey.Password].ToString(); RoomProperties.Remove(RoomOptionKey.Password); } if (RoomProperties.ContainsKey(RoomOptionKey.IsVisible)) { IsVisible = (bool)RoomProperties[RoomOptionKey.IsVisible]; RoomProperties.Remove(RoomOptionKey.IsVisible); } if (RoomProperties.ContainsKey(RoomOptionKey.HostPlayerId)) { HostPlayerId = RoomProperties[RoomOptionKey.HostPlayerId].ToString(); RoomProperties.Remove(RoomOptionKey.HostPlayerId); } if (RoomProperties.ContainsKey(RoomOptionKey.HostPlayerName)) { HostPlayerNickname = RoomProperties[RoomOptionKey.HostPlayerName].ToString(); RoomProperties.Remove(RoomOptionKey.HostPlayerName); } if (RoomProperties.ContainsKey(RoomOptionKey.KeyPlayerId)) { KeyPlayerId = RoomProperties[RoomOptionKey.KeyPlayerId].ToString(); RoomProperties.Remove(RoomOptionKey.KeyPlayerId); } if (RoomProperties.ContainsKey(RoomOptionKey.KeyPlayerName)) { KeyPlayerNickname = RoomProperties[RoomOptionKey.KeyPlayerName].ToString(); RoomProperties.Remove(RoomOptionKey.KeyPlayerName); } if (RoomProperties.ContainsKey(RoomOptionKey.BlockedPlayerIdList)) { BlockedPlayerIdList = RoomProperties[RoomOptionKey.BlockedPlayerIdList] as Dictionary <string, string>; RoomProperties.Remove(RoomOptionKey.BlockedPlayerIdList); } else { BlockedPlayerIdList = new Dictionary <string, string>(); } }