Examples
- Clans/Guilds - Entity groups can be used to describe a set of players who are playing together regularly, for whatever social glue that holds them together on a long-term basis.
- Parties - Entity groups can be used for short-term groups created to allow individual players to accomplish an immediate goal, and then easily disbanded afterward.
- Chat Channels - Short or long term chat channels can be defined as an entity group.
- In-Game subscription to information - Do you have a single-instance legendary item in your game? Do players want constant updates about what is happening with that item? Create an entity group focused on that item, with all player entities interested in the item as members.
- Object data
- File data
- Profiles
Groups have a default limit of 1000 members per group and only support players and characters as members
Using entity groups
When creating a group, the first entity added to the group is placed in an Admin role (this guide refers to that entity as the owner, for simplicity). The owner will then be able to invite new members, create new roles with a wide variety of customizable permissions, modify member roles, kick members, etc. Additionally, the same entity functions that exist for entities also function for groups, so you’ll be able to save JSON objects and files directly to the group to save arbitrary game-specific data. The code example that is provided below should give you a head start on basic guild interaction. It allows you to create groups, add and remove members, and delete the group. It’s meant to be a starting point, and doesn’t demonstrate any of the roles or permissions.Deconstructing the example
This example is built as a controller, which saves minimal data to a local cache (PlayFab being the authoritative data layer), and provides a way to perform CRUD operations on groups. Let’s take a look at some of the functions in the example provided:-
OnSharedError- This is a typical pattern with PlayFab examples. The simplest way to handle an error is to report it. Your game client will probably have much more sophisticated error handling logic. -
ListMembership- This callsListMembershipto determine all the groups that the given entity belongs to. Players want to know the groups they have already joined. -
CreateGroup/DeleteGroup- Mostly self-explanatory. This example demonstrates updating the local group info cache when these calls are executed successfully. -
InviteToGroup/ApplyToGroup- Joining a group is a two-step process, and it can be activated both directions:- A player can ask to join a group.
- A group can invite a player.
-
AcceptGroupInvitation/AcceptGroupApplication- The second step of the join process. The responding entity accepts the invitation, completing the process of making the player a part of the group. -
RemoveMembers- Members with authority to do so (defined by their role permissions), will be able to kick members from a group.
Server vs client
Like all new entity API methods, there’s no distinction between the server API and the client API. The action is performed by the caller, according to how the process was authenticated. A client will be identified as such, and will call these methods as a title player entity, and their roles and permissions within the group will be evaluated with every call, ensuring they have permission to perform this action. A server is authenticated with the samedeveloperSecretKey, which identifies that process as a title entity. A title bypasses the role checks, and API calls executed by a title will only fail if the action is impossible to perform, in an instance such as if an entity can’t be removed if they aren’t a member.
