In order to maintain a healthy and fair playing environment, it may make sense for the game to have the ability for streamers to remove certain offending players from the game. Additionally, players that are too problematic can also be banned entirely from a streamer's game, preventing them from returning to any of the streamer's games for a certain amount of hours. (or permanently)
The actor can be configured to prevent players from playing by sending them a "boot" message. The boot message can then be interpreted by the mobile device to have the player be disconnected from the game, preventing them from playing.
Additionally, the STREAMSIX SDK has first class support for the ability to ban players from a given stream. When a streamer decides to ban a player from their game, the player will be banned for a given amount of time. The timeframes can either be fixed by the developer, or can be specified on a more fine-grain level (in hours) by the streamer, depending on how the functionality is implemented. When a player who is banned joins the game, the actor can then check to see if the player is banned for that particular stream and then decide to prevent them from entry by booting them.
Additionally, you could also implement a temporary list of kicked players in the mothership and have it synced across all satellites, to prevent players from joining for a given session, but allow them to join future sessions. This is referred to in this document as "kicking" players. You can also choose to not have a list at all and just have the streamer simply boot the player out, allowing them to join immediately after. This is referred to in this document as "ejecting" players.
Ultimately, it's up to you the developer on how you want to implement your community management strategy. The STREAMSIX SDK is flexible in that you have the ability to manage troublesome players as you please, and the banning functionality will allow you to ensure that streamer bans are maintained across sessions.
The following guide will show you how to ban a player, and also how you can boot the players from the game. It is up to you from there how you want to handle kicking/banning/ejecting of users based on how you see fit.
Banning Players
First, you will need to incorporate a new message handler into your actor in order to handle the ban request. This will consist of adding a new network ID to represent the ban action, and then adding a function to handle messages of that ID. Assuming your mothership implements the MothershipReceiver
interface, you can add a check inside the OnMessage
method of your MothershipReceiver
-derived class.
switch (msg.Key){...case (int)NetworkId.BanPlayer:{ProcessPlayerBan(value);break;}...}
In this example, we have a method called ProcessPlayerBan
, and this will handle the ban. This method will call the Entity Manager, providing the ID of the streamer, the ID of the player to ban, and how long to ban the player in hours.
await mActor.UserData.BanPlayers(playerBan.hostPlayerID, new List<BannedUser>(){new BannedUser(){Id = playerBan.bannedPlayerID,ExpireAt = (int)expireAt,}});
Once this request succeeds, the player should be banned for the number of hours specified in ExpireAt
. Any request to mActor.UserData.GetBannedPlayers
given the streamer's player ID will return that banned player in the list of banned players until their ban expires.
Booting Players
You can then send a message to the player to boot them from the game.
// TODO update this code to be from C# actordata = new Dictionary<int, object>(){{(int)NetworkIDs.BootPlayer, new BootData(){playerId = playerId,reason = BootReason.Banned,}}};NetworkManager.SendMsgToControllers(data, new List<string>(){playerId});
In the mobile client code, you can then handle it like the following:
switch (item.Key){...case (int)NetworkIDs.BootPlayer:OnBooted(value);break;...}
The OnBooted
function would look like the following:
private void OnBooted(string value){Debug.Log("Played booted from the game.");BootData bootData = JsonConvert.DeserializeObject<BootData>(value);// perform any action you need to do to prevent player from playing and to show them the banned screen insteadStateManager.LoadState(StateId.Booted, bootData);}
Booting Banned players
You can combine both techniques from above to prevent players from joining if they're banned. You can do this by handling it in the satellite upon players joining:
private async void HandleJoinedPlayer(Dictionary<string, object> playerData){string playerID = (string)playerData["playerID"];Debug.Log("Handling player " + playerID);// check for banList<BannedUser> bannedUsers = await mActor.UserData.GetBannedPlayers(mGameConfig.streamerPlayerID);foreach (var player in bannedUsers){if (player.Id == playerID){var playerMsg = new Dictionary<int, object>() { { (int)NetworkId.BootPlayer, new PlayerBoot() {playerID = playerID,reason = BootReason.Banned,}} };var playerStr = JsonConvert.SerializeObject(playerMsg);var playerBytes = UTF8Encoding.UTF8.GetBytes(playerStr);mSender.SendToController(playerBytes, playerID);return;}}}
The mobile app's OnBooted
function will then trigger upon player attempting to join, preventing the player from playing.