private static object DeserializeExcludedActorInfo(byte[] info) { using (var stream = new MemoryStream(info)) { object o; if (!protocol.TryParse(stream, out o)) { return null; } var result = new ExcludedActorInfo { UserId = (string)o }; if (!protocol.TryParse(stream, out o)) { return null; } result.Reason = (byte)o; return result; } }
protected virtual void UpdateGameStateOnMaster( byte? newMaxPlayer = null, bool? newIsOpen = null, bool? newIsVisble = null, object[] lobbyPropertyFilter = null, Hashtable gameProperties = null, string[] newUserId = null, string removedUserId = null, bool reinitialize = false, string[] inactiveList = null, ExcludedActorInfo[] excludedActorInfos = null, string[] expectedList = null, bool? checkUserIdOnJoin = null) { if (reinitialize && this.ActorsManager.ActorsCount == 0 && this.ActorsManager.InactiveActorsCount == 0) { Log.WarnFormat("Reinitialize tried to update GameState with ActorCount = 0 - {0}." , this.ToString()); return; } if (Log.IsDebugEnabled) { Log.DebugFormat("UpdateGameStateOnMaster: game - '{0}', reinitialize:{1}", this.Name, reinitialize); } var updateGameEvent = new UpdateGameEvent { GameId = this.Name, ActorCount = (byte)this.ActorsManager.ActorsCount, Reinitialize = reinitialize, MaxPlayers = newMaxPlayer, IsOpen = newIsOpen, IsVisible = newIsVisble, IsPersistent = this.IsPersistent, InactiveCount = (byte)this.ActorsManager.InactiveActorsCount, PropertyFilter = lobbyPropertyFilter, CheckUserIdOnJoin = checkUserIdOnJoin, }; // TBD - we have to send this in case we are re-joining and we are creating the room (load) if (reinitialize) { updateGameEvent.LobbyId = this.LobbyId; updateGameEvent.LobbyType = (byte)this.LobbyType; } if (gameProperties != null && gameProperties.Count > 0) { updateGameEvent.GameProperties = gameProperties; } if (newUserId != null) { updateGameEvent.NewUsers = newUserId; } if (removedUserId != null) { updateGameEvent.RemovedUsers = new[] { removedUserId }; } if (excludedActorInfos != null) { updateGameEvent.ExcludedUsers = excludedActorInfos; } if (expectedList != null) { updateGameEvent.ExpectedUsers = expectedList; } this.UpdateGameStateOnMaster(updateGameEvent); }