Groups
Overview
AccelByte Gaming Services (AGS) Starter Groups service allows players to gather together to chat and play matches with one another. This service allows players to create, join, and invite other players to groups. Group admins can also manage join requests and add members to or from their groups. AGS Starter’ Groups service can be integrated with other services such as the Lobby, Statistics, and Leaderboards to extend its functionality. For example, you can create groups for players that have achieved a specific level or rank in your game, helping to make groups more evenly balanced and boost player engagement and enjoyment in your games.
How It Works
Group Types
There are three types of groups that can be created:
- Open Groups are searchable and do not require any approval to join. A player can search for the group using the Group Name or Group Code, and then join the group without waiting for a group admin to approve their request.
- Public Groups are searchable but require permission to join. When a player tries to join, they must wait for a group admin to approve their request. These groups often have membership requirements, such as only allowing players with an MMR of more than 100 to join the group.
- Private Groups can’t be searched for and require permission to join. Players can only join these groups if they’ve been invited by an admin.
Managing Groups in the Admin Portal
Create a New Group Role
Open the desired game title and expand the Game Management, select Group Management, and click Roles.
On the Group Roles page, click Add Role.
The Add Role form will appear. Type the name for your new role and click Submit when you’re done.
Add New Permissions to a Group Role
Go to the Group Role you created earlier and click the Add Permission button.
The Add Permission form will appear.
Input the type of Permission by using the standard resource format, e.g., GROUP:JOIN, GROUP:KICK. Separate permissions with a comma (,).
Choose the Action of the permission.
Refer to the table below for the types of permissions you can implement.
Usage Permission Action Delete and update existing group GROUP Read, Update, Delete Invite a player to a group GROUP:INVITE Create Accept and reject group join request GROUP:JOIN Create Kick a player from a group GROUP:KICK Create Get list of all member roles GROUP:ROLE Read Assign a role to a member GROUP:ROLE Update Click Add when you’re done.
Create a New Group Configuration
Expand the Group Management menu and click the Create Configuration button.
The Create Configuration form will appear. Fill in the required fields:
- Input the configuration Code with the appropriate format, e.g., group-clan.
- Input the configuration Name.
- Input a Description of the configuration.
- Input the Maximum Group Members as a number.
- Select the Group Admin Role associated with this group.
- Select the Group Member Role associated with this group.
Click Add. Your new configuration will be added to the list.
Add Custom Attributes
In the Group Management dropdown of the Admin Portal, click the List menu.
Choose the group you want to add the custom attributes to by clicking the View button. Make sure that you have permission to add the required attributes to a group.
On the Group Details, click the Add Custom Attributes button.
Fill out the custom attributes in JSON format.
Once completed, click Save.
Implement Groups using the Client SDKs
Managing Groups
Create a New Group
You can create a new group once you have a group configuration in your namespace. The members of your group will be admins by default.
- Unreal Engine
- Unity
FAccelByteModelsGroupRules GroupRules;
FAccelByteModelsCreateGroupRequest GroupConfiguration;
GroupConfiguration.GroupName = "MyNewGroupName";
GroupConfiguration.GroupType = EAccelByteGroupType::OPEN;
GroupConfiguration.GroupMaxMember = 25;
GroupConfiguration.GroupDescription = "MyNewGroupDescription";
GroupConfiguration.GroupIcon = "https://example.com";
GroupConfiguration.GroupRegion = "US";
GroupConfiguration.GroupRules = GroupRules;
GroupConfiguration.ConfigurationCode = "MyConfiguration Code";
FRegistry::Group.CreateGroup(
GroupConfiguration,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if CreateGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateGroup has an error
}));
RuleInformation ruleInformation = new RuleInformation {
ruleAttribute = "MyRuleAttribute",
ruleCriteria = RuleCriteria.MAXIMUM,
ruleValue = 50.0f
};
Rules rules = new Rules {
allowedAction = AllowedAction.joinGroup,
ruleDetail = [ruleInformation]
};
GroupRules groupRules = new GroupRules {
groupCustomRule = {},
groupPredefinedRules = [rules]
};
CreateGroupRequest createGroupRequest = new CreateGroupRequest{
groupName = "MyNewGroupName",
groupType = GroupType.OPEN,
groupMaxMember = 25,
groupDescription = "MyNewGroupDescription",
groupIcon = "https://example.com",
groupRegion = "US",
groupRules = groupRules,
configurationCode = "MyConfiguration Code",
customAttributes = new Dictionary<string, object>
{
{ "sword", 3 },
{ "armor", 7 }
}
};
AccelBytePlugin.GetGroup().CreateGroup(createGroupRequest, result =>
{
if (result.IsError)
{
// Do something if CreateGroup has an error
Debug.Log($"Error CreateGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if CreateGroup has been successful
}
});
Retrieve a List of Groups
Use the following function to search for a group by its name or region. The results will be paginated, and you can use offset and limit parameters to limit the list. This function only shows PUBLIC and OPEN groups.
- Unreal Engine
- Unity
FAccelByteModelsGetGroupListRequest SearchConfiguration;
SearchConfiguration.GroupName = "SomeGroupName"; // You can leave it blank if you want to fetch all the groups
SearchConfiguration.GroupRegion = "US"; // You can leave it blank if you want to fetch all the groups
SearchConfiguration.Offset = 0;
SearchConfiguration.Limit = 99;
FRegistry::Group.GetGroupList(
SearchConfiguration,
THandler<FAccelByteModelsGetGroupListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetGroupListResponse& Result)
{
// Do something if GetGroupList has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupList has an error
}));
string groupName = "SomeGroupName"; // You can leave it blank if you want to fetch all the groups
string groupRegion = "US"; // You can leave it blank if you want to fetch all the groups
int offset = 0;
int limit = 99;
AccelBytePlugin.GetGroup().SearchGroups(groupName, groupRegion, offset, limit, result =>
{
if (result.IsError)
{
// Do something if SearchGroups has an error
Debug.Log($"Error SearchGroups, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if SearchGroups has been successful
}
});
Retrieve Group Information
Use the following function to retrieve information about a group by using the Group ID.
- Unreal Engine
- Unity
FString groupId = "SomeGroupId";
FRegistry::Group.GetGroup(
groupId,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if GetGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroup has been successful
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().GetGroup(groupId, result =>
{
if (result.IsError)
{
// Do something if GetGroup has an error
Debug.Log($"Error GetGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetGroup has been successful
}
});
Retrieve a Player’s Group Information
Use the following function to retrieve a player’s group information. If the player you requested doesn’t belong to any group, the returned status will be ErrorCode.UserNotBelongToAnyGroup.
- Unreal Engine
- Unity
AccelBytePlugin.GetGroup().GetMyGroupInfo(result =>
{
if (result.IsError)
{
// Do something if GetMyGroupInfo has an error
Debug.Log($"Error GetMyGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetMyGroupInfo has been successful
}
});
AccelBytePlugin.GetGroup().GetMyGroupInfo(result =>
{
if (result.IsError)
{
// Do something if GetMyGroupInfo has an error
Debug.Log($"Error GetMyGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetMyGroupInfo has been successful
}
});
Retrieve Other Players' Group Information
Use the following function to call the group information of other users with a specific user ID.
- Unreal Engine
- Unity
FString UserId = "OtherPlayerUserId";
FRegistry::Group.GetUserGroupInfoByUserId(
UserId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if GetUserGroupInfoByUserId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserGroupInfoByUserId has an error
}));
string userid = "SomeUserId";
AccelBytePlugin.GetGroup().GetOtherGroupInfo(userId, result =>
{
if (result.IsError)
{
// Do something if GetOtherGroupInfo has an error
Debug.Log($"Error GetOtherGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetOtherGroupInfo has been successful
}
});
Retrieve a Group’s Member List
Use the following function to retrieve a group’s member list.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FAccelByteModelsGetGroupMembersListByGroupIdRequest SearchGroupMemberConfiguration;
FRegistry::Group.GetGroupMembersListByGroupId(
GroupId,
SearchGroupMemberConfiguration,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if GetGroupMembersListByGroupId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupMembersListByGroupId has an error
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().GetGroupMemberList(groupId, result =>
{
if (result.IsError)
{
// Do something if GetGroupMemberList has an error
Debug.Log($"Error GetGroupMemberList, Error Code: {result.Error.Code} Error Code: {result.Error.Message}");
}
else
{
// Do something if GetGroupMemberList has been successful
}
});
Update Group Information
Use the following function to update a group’s information, such as its name, icon, description, region, or type. Only members with an admin role can update the group’s information.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FAccelByteModelsGroupUpdatable UpdateGroupConfiguration;
FRegistry::Group.UpdateGroup(
GroupId,
True, // set True if you want to replace all group informations
UpdateGroupConfiguration,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroup has an error
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().UpdateGroup(groupId, updateGroupRequest, result =>
{
if (result.IsError)
{
// Do something if UpdateGroup has an error
Debug.Log($"Error UpdateGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if UpdateGroup has been successful
}
});
Update a Group’s Custom Attributes
Use the following function to update a group’s custom attributes. Only members with an admin role can update the group’s custom attributes.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FAccelByteModelsUpdateGroupCustomAttributesRequest UpdateGroupCustomAttributeGroup;
FRegistry::Group.UpdateGroupCustomAttributes(
GroupId,
UpdateGroupCustomAttributeGroup,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroupCustomAttributes has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroupCustomAttributes has an error
}));
Dictionary<string, object> customAttributes = new Dictionary<string, object>
{
{ "requirementLevel", 50 },
{ "requirementItem", 25 }
};
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().UpdateGroupCustomAttributes(groupId, customAttributes, result =>
{
if (result.IsError)
{
// Do something if UpdateGroupCustomAttributes has an error
Debug.Log($"Error UpdateGroupCustomAttributes, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if UpdateGroupCustomAttributes has been successful
}
});
Group Interaction
Join a Group
Players can request to join open or public groups. An OPEN group will allow players to automatically join, whereas a join request to a PUBLIC group will need to be approved by an admin before the player can join.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FRegistry::Group.JoinGroup(
GroupId,
THandler<FAccelByteModelsJoinGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsJoinGroupResponse& Result)
{
// Do something if JoinGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if JoinGroup has an error
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().JoinGroup(groupId, result =>
{
if (result.IsError)
{
// Do something if JoinGroup has an error
Debug.Log($"Error JoinGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if JoinGroup has been successful
}
});
Cancel Join Request
After a player requests to join a group, that request can be canceled.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FRegistry::Group.CancelJoinGroupRequest(
GroupId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if CancelJoinGroupRequest has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CancelJoinGroupRequest has an error
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().CancelJoinGroupRequest(groupId, result =>
{
if (result.IsError)
{
// Do something if CancelJoinGroupRequest has an error
Debug.Log($"Error CancelJoinGroupRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if CancelJoinGroupRequest has been successful
}
});
Leave a Group
To leave a group, you can use this function.
- Unreal Engine
- Unity
FRegistry::Group.LeaveGroup(
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if LeaveGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if LeaveGroup has an error
}))
AccelBytePlugin.GetGroup().LeaveGroup(result =>
{
if (result.IsError)
{
// Do something if LeaveGroup has an error
Debug.Log($"Error LeaveGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if LeaveGroup has been successful
}
});
Invite a Player o a Group
Group admins can also invite players to join their group. A PRIVATE group can use this function to add new members. Players need to accept the invitation before they can join the group.
- Unreal Engine
- Unity
FString UserId = "SomeUserId";
FRegistry::Group.InviteUserToGroup(
UserId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if InviteUserToGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if InviteUserToGroup has an error
}));
string otherUserId = "SomeOtherUserId";
AccelBytePlugin.GetGroup().InviteOtherUserToGroup(otherUserId, result =>
{
if (result.IsError)
{
// Do something if InviteOtherUserToGroup has an error
Debug.Log($"Error InviteOtherUserToGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if InviteOtherUserToGroup has been successful
}
});
string userId = "123456789";
AccelBytePlugin.GetGroup().InviteOtherUserToGroup(userId, result =>
{
Debug.Log("Successfully invite user to the group!");
});
Kick a Group Member
Group admins can also kick group members out of the group.
- Unreal Engine
- Unity
FString UserId = "SomeUserId";
FRegistry::Group.KickGroupMember(
UserId,
THandler<FAccelByteModelsKickGroupMemberResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsKickGroupMemberResponse& Result)
{
// Do something if KickGroupMember has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if KickGroupMember has an error
}));
string otherUserId = "SomeOtherUserId";
AccelBytePlugin.GetGroup().KickGroupMember(otherUserId, result =>
{
if (result.IsError)
{
// Do something if KickGroupMember has an error
Debug.Log($"Error KickGroupMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if KickGroupMember has been successful
}
});
Get a List of Group Invitation Requests
Players can get the list of group invitation requests, to either accept or reject these invitations.
- Unreal Engine
- Unity
FAccelByteModelsLimitOffsetRequest GroupInvitationListConfiguration;
FRegistry::Group.GetGroupInvitationRequests(
GroupInvitationListConfiguration,
THandler<FAccelByteModelsGetMemberRequestsListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetMemberRequestsListResponse& Result)
{
// Do something if GetGroupInvitationRequests has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupInvitationRequests has an error
}));
AccelBytePlugin.GetGroup().GetGroupInvitationRequests(result =>
{
if (result.IsError)
{
// Do something if GetGroupInvitationRequests has an error
Debug.Log($"Error GetGroupInvitatioNRequests, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetGroupInvitationRequests has been successful
}
});
Accept Group Invitation Request
After getting the invitation list, players can accept an invitation.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FRegistry::Group.AcceptGroupInvitation(
GroupId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if AcceptGroupInvitation has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AcceptGroupInvitation has an error
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().AcceptGroupInvitation(groupId, result =>
{
if (result.IsError)
{
// Do something if AcceptGroupInvitation has an error
Debug.Log($"Error AcceptGroupInvitation, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if AcceptGroupInvitation hasbeen successful
}
});
Reject Group Invitation Request
Players can also reject any invitation request.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FRegistry::Group.RejectGroupInvitation(
GroupId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if RejectGroupInvitation has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if RejectGroupInvitation has an error
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().RejectGroupInvitation(groupId, result =>
{
if (result.IsError)
{
// Do something if RejectGroupInvitation has an error
Debug.Log($"Error RejectGroupInvitation, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if RejectGroupInvitation has been successful
}
});
Get List of Group Member Join Requests
Group admins can get the list of group member join requests, to either approve or reject them.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FAccelByteModelsLimitOffsetRequest GroupRequestListConfiguration;
FRegistry::Group.GetGroupJoinRequests(
GroupId,
GroupRequestListConfiguration,
THandler<FAccelByteModelsGetMemberRequestsListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetMemberRequestsListResponse& Result)
{
// Do something if GetGroupJoinRequests has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupjoinRequests has an error
}));
string groupId = "123456789";
AccelBytePlugin.GetGroup().GetGroupJoinRequests(groupId, result =>
{
foreach(var request in result.Value.data)
{
Debug.Log("UserId: " + request.userId);
}
});
Accept Group Member Join Request
After getting the list of join requests, a group admin can accept them to the group.
- Unreal Engine
- Unity
FString UserId = "SomeUserId";
FRegistry::Group.AcceptGroupJoinRequest(
UserId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if AcceptGroupJoinRequest has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AcceptGroupJoinRequest has an error
}));
string otherUserId = "SomeOtherUserId";
AccelBytePlugin.GetGroup().AcceptOtherJoinRequest(otherUserId, result =>
{
if (result.IsError)
{
// Do something if AcceptOtherJoinRequest has an error
Debug.Log($"Error AcceptOtherJoinRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if AcceptOtherJoinRequest has been successful
}
});
Reject Group Member Join Request
Group admin can also reject any member join request.
- Unreal Engine
- Unity
FString UserId = "SomeUserId";
FRegistry::Group.RejectGroupJoinRequest(
UserId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if RejectGroupJoinRequest has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if RejectGroupJoinRequest has an error
}));
string otherUserId = "SomeOtherUserId";
AccelBytePlugin.GetGroup().RejectOtherJoinRequest(otherUserId, result =>
{
if (result.IsError)
{
// Do something if RejectOtherJoinRequest has an error
Debug.Log($"Error RejectOtherJoinRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if RejectOtherJoinRequest has been successful
}
});
Retrieve Bulk Users’ Presence
You can use this endpoint to get users’ presence information in bulk.
- Unreal Engine
- Unity
TArray<FString> UserIds;
FRegistry::Lobby.BulkGetUserPresence(
UserIds,
THandler<FAccelByteModelsBulkUserStatusNotif>::CreateWeakLambda(this, [this](const FAccelByteModelsBulkUserStatusNotif& Result)
{
// Do something if BulkGetUserPresence has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if BulkGetUserPresence has an error
}));
var userIds = new List<string>();
userIds.Add("SomeTargetUserId1");
userIds.Add("SomeTargetUserId2");
userIds.Add("SomeTargetUserId3");
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().BulkGetUserPresence(userIds.ToArray(), result =>
{
if (result.IsError)
{
// Do something if BulkGetUserPresence has an error
Debug.Log($"Error BulkGetUserPresence, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if BulkGetUserPresence has been successful
}
});
Group Roles
Every group member has roles assigned to them, which can be used to restrict or allow access to features such as: inviting a member, kicking a member, etc. Every group member will automatically be assigned to the default member role that is already defined in the group configuration. This can be either an admin group role or a member group role.
Retrieve a List of Group Member Roles
An admin can get a list of the member roles that have already been created in the Admin Portal.
- Unreal Engine
- Unity
FAccelByteModelsLimitOffsetRequest GroupRoleListConfiguration;
FRegistry::Group.GetMemberRoles(
GroupRoleListConfiguration,
THandler<FAccelByteModelsGetMemberRolesListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetMemberRolesListResponse& Result)
{
// Do something if GetMemberRoles has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetMemberRoles has an error
}));
AccelBytePlugin.GetGroup().GetMemberRoles(result =>
{
if (result.IsError)
{
// Do something if GetMemberRoles has an error
Debug.Log($"Error GetMemberRoles, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetMemberRoles has been successful
}
});
Promote a Member to a Role
An admin can promote a member to a specific role, as long as the role has been defined for that group.
- Unreal Engine
- Unity
FString TargetRoleId = "SomeRoleId";
FAccelByteModelsUserIdWrapper MemberId;
MemberId.UserId = "SomeMemberId";
FRegistry::Group.AssignMemberRole(
TargetRoleId,
MemberId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if AssignMemberRole has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AssignMemberRole has an error
}));
string memberRoleId = "SomeMemberRoleId";
string userId = "SomeUserId";
AccelBytePlugin.GetGroup().AssignRoleToMember(memberRoleId, userid, result =>
{
if (result.IsError)
{
// Do something if AssignRoleToMember has an error
Debug.Log($"Error AssignRoleToMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if AssignRoleToMember has been successful
}
});
Remove a Member’s Role
An admin can also remove a role from a member.
- Unreal Engine
- Unity
FString TargetRoleId = "SomeRoleId";
FAccelByteModelsUserIdWrapper MemberId;
MemberId.UserId = "SomeMemberId";
FRegistry::Group.DeleteMemberRole(
TargetRoleId,
MemberId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if DeleteMemberRolehas been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteMemberRolehas an error
}));
string memberRoleId = "SomeMemberRoleId";
string userId = "SomeUserId";
AccelBytePlugin.GetGroup().RemoveRoleFromMember(memberRoleId, userid, result =>
{
if (result.IsError)
{
// Do something if RemoveRoleFromMember has an error
Debug.Log($"Error RemoveRoleFromMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if RemoveRoleFromMember has been successful
}
});
Group Notifications
Some group activity will trigger notifications that will be sent to individual players, to group admins, or to all group members. The notification payload will be a JSON formatted string that contains data related to the triggered activity. To retrieve these notifications, you need to add a callback to the OnNotification function.
- Unity
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().OnNotification += result =>
{
if (result.IsError)
{
// Do something if OnNotification has an error
Debug.Log($"Error OnNotification, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if OnNotification has been successful
}
};
Group Invitation Notifications
Here’s an example of the payload for a notification sent to a player when they’ve been invited to join a group:
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"kind": "invitation"
}
Group Acceptance Notifications
Here’s an example of the payload for a notification sent to a player when their request to join a group has been accepted:
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"kind": "accepted-request"
}
Group Rejection Notifications
Here’s an example of the payload for a notification sent to a player when their request to join a group has been rejected:
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"kind": "rejected-request"
}
New Group Member Notifications
Here’s an example of the payload for a notification sent to all group members when a new member has joined their group:
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMemberId",
"kind": "new-member"
}
Member Request Notifications
Here’s an example of the payload for a notification sent to group admins when a player has requested to join their group:
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMemberId",
"kind": "join-request"
}
Member Role Assignment Notifications
Here’s an example of the payload for a notification sent to a player when a group admin has assigned a role to them:
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMemberId",
"roleId": "roelId",
"kind": "assigned-role"
}
Here’s an example of the payload for a notification if a group admin removes a role from a player:
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMemberId",
"roleId": "roelId",
"kind": "removed-role"
}