グループをゲームに統合する
Overview
AccelByte Gaming Services (AGS) Group provides game developers a way to boost interaction between players that can increase overall player retention by allowing players to form a group, gather, interact, and collaborate to achieve common goals. In this guide, you will learn how to integrate groups into your game using the AGS Group service with the Client SDK.
This article walks you through how to:
- Integrate groups into your game with Client SDKs.
- Allow players to manage groups.
- Retrieve group information.
- Allow players to interact with groups.
- Send group-related notifications to the player.
Prerequisites
You will need access to:
- The AGS Admin Portal.
- The AccelByte Unreal or Unity SDK, including the required permissions:
- Client ID
- Client Secret
- The AGS Group API documentation for reference.
Manage groups
The following sections detail how to integrate group management into your game.
Create a new group
You can allow your players to create a new group once you have a group configuration in your namespace. The player who created the group will be group admin by default. Use the following function to create a new group:
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FAccelByteModelsCreateGroupRequest RequestContent = {};
RequestContent.ConfigurationCode = "YourGroupConfigurationCode";
RequestContent.GroupName = "YourGroupName";
RequestContent.GroupDescription = "YourGroupDescription";
RequestContent.GroupMaxMember = 50;
RequestContent.GroupType = EAccelByteGroupType::PUBLIC;
ApiClient->Group.CreateGroup(RequestContent, THandler<FAccelByteModelsGroupInformation>::CreateLambda([](const FAccelByteModelsGroupInformation& Result)
{
// Do something if CreateGroup succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateGroup fails
}));
CreateGroupRequest createGroupRequest = new CreateGroupRequest
{
configurationCode = "YourGroupConfigurationCode",
groupName = "YourGroupName",
groupDescription = "YourGroupDescription",
groupMaxMember = 50,
groupType = GroupType.PUBLIC
};
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().CreateGroup(createGroupRequest, result =>
{
if (result.IsError)
{
// Do something if CreateGroup fails
Debug.Log($"Error CreateGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if CreateGroup succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FAccelByteModelsCreateGroupRequest RequestContent = {};
RequestContent.ConfigurationCode = "YourGroupConfigurationCode";
RequestContent.GroupName = "YourGroupName";
RequestContent.GroupDescription = "YourGroupDescription";
RequestContent.GroupMaxMember = 50;
RequestContent.GroupType = EAccelByteGroupType::PUBLIC;
ApiClient->Group.CreateV2Group(RequestContent, THandler<FAccelByteModelsGroupInformation>::CreateLambda([](const FAccelByteModelsGroupInformation& Result)
{
// Do something if CreateV2Group succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateV2Group fails
}));
CreateGroupRequest createGroupRequest = new CreateGroupRequest
{
configurationCode = "YourGroupConfigurationCode",
groupName = "YourGroupName",
groupDescription = "YourGroupDescription",
groupMaxMember = 50,
groupType = GroupType.PUBLIC
};
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().CreateGroupV2(createGroupRequest, result =>
{
if (result.IsError)
{
// Do something if CreateGroupV2 fails
Debug.Log($"Error CreateGroupV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if CreateGroupv2 succeeds
});
Update group information
Information that is tied to a specific group, such as a group name, icon, description, region, or type, can be updated. Only members with an admin role can update the group's information. Use this function to update group information:
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
bool bCompletelyReplace = true;
FAccelByteModelsGroupUpdatable UpdateContent = {};
UpdateContent.GroupName = "UpdatedGroupName";
UpdateContent.GroupDescription = "UpdatedGroupDescription";
UpdateContent.GroupType = EAccelByteGroupType::PRIVATE;
ApiClient->Group.UpdateGroup(GroupId, bCompletelyReplace, UpdateContent, THandler<FAccelByteModelsGroupInformation>::CreateLambda([](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroup succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroup fails
}));
string groupId = "YourGroupId";
UpdateGroupRequest updateGroupRequest = new UpdateGroupRequest
{
groupName = "UpdatedGroupName",
groupDescription = "UpdatedGroupDescription",
groupType = GroupType.PRIVATE
};
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().UpdateGroup(groupId, updateGroupRequest, result =>
{
if (result.IsError)
{
// Do something if UpdateGroup fails
Debug.Log($"Error UpdateGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if UpdateGroup succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FAccelByteModelsUpdateGroupRequest UpdateContent = {};
UpdateContent.GroupName = "UpdatedGroupName";
UpdateContent.GroupDescription = "UpdatedGroupDescription";
UpdateContent.GroupType = EAccelByteGroupType::PRIVATE;
ApiClient->Group.UpdateV2Group(GroupId, UpdateContent, THandler<FAccelByteModelsGroupInformation>::CreateLambda([](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateV2Group succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateV2Group fails
}));
string groupId = "YourGroupId";
UpdateGroupRequest updateGroupRequest = new UpdateGroupRequest
{
groupName = "UpdatedGroupName",
groupDescription = "UpdatedGroupDescription",
groupType = GroupType.PRIVATE
};
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().UpdateGroupV2(groupId, updateGroupRequest, result =>
{
if (result.IsError)
{
// Do something if UpdateGroupV2 fails
Debug.Log($"Error UpdateGroupV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if UpdateGroupV2 succeeds
});
Update a group's custom attributes
You can update a group's custom attributes separately using this function. Just like updating group information, only members with an admin role can update the group's custom attributes.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
FJsonObjectWrapper UpdatedCustomAttributes;
UpdatedCustomAttributes.JsonObject = MakeShared<FJsonObject>();
UpdatedCustomAttributes.JsonObject->SetStringField("Attribute String Key", "Updated Attribute");
FAccelByteModelsUpdateGroupCustomAttributesRequest UpdateContent = {};
UpdateContent.CustomAttributes = UpdatedCustomAttributes;
ApiClient->Group.UpdateGroupCustomAttributes(GroupId, UpdateContent, THandler<FAccelByteModelsGroupInformation>::CreateLambda([](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroupCustomAttributes succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroupCustomAttributes fails
}));
string groupId = "YourGroupId";
Dictionary<string, object> updateGroupRequest = new Dictionary<string, object>
{
{"Attribute String Key", "Updated Attribute" }
};
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().UpdateGroupCustomAttributes(groupId, updateGroupRequest, result =>
{
if (result.IsError)
{
// Do something if UpdateGroupCustomAttributes fails
Debug.Log($"Error UpdateGroupCustomAttributes, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if UpdateGroupCustomAttributes succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
FJsonObjectWrapper UpdatedCustomAttributes;
UpdatedCustomAttributes.JsonObject = MakeShared<FJsonObject>();
UpdatedCustomAttributes.JsonObject->SetStringField("Attribute String Key", "Updated Attribute");
FAccelByteModelsUpdateGroupCustomAttributesRequest UpdateContent = {};
UpdateContent.CustomAttributes = UpdatedCustomAttributes;
ApiClient->Group.UpdateV2GroupCustomAttributes(GroupId, UpdateContent, THandler<FAccelByteModelsGroupInformation>::CreateLambda([](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateV2GroupCustomAttributes succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateV2GroupCustomAttributes fails
}));
string groupId = "YourGroupId";
Dictionary<string, object> updateGroupRequest = new Dictionary<string, object>
{
{"Attribute String Key", "Updated Attribute" }
};
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().UpdateGroupCustomAttributesV2(groupId, updateGroupRequest, result =>
{
if (result.IsError)
{
// Do something if UpdateGroupCustomAttributesV2 fails
Debug.Log($"Error UpdateGroupCustomAttributesV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if UpdateGroupCustomAttributesV2 succeeds
});
Display group information
The following sections detail how to display different types of group information.
Retrieve a list of groups
You can allow your players to search the available groups created by the players by searching using a group name or region. The results will be appear in pages, and you can use offset and limit parameters to limit the list. Use the following function to retrieve a list of groups:
The function below only shows PUBLIC and OPEN groups. You can learn more about group types in the section on group interactions.
- Unreal Engine
- Unity
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FAccelByteModelsGetGroupListRequest FilterContent = {};
FilterContent.GroupName = "YourGroupName";
FilterContent.GroupRegion = "US";
ApiClient->Group.GetGroupList(FilterContent, THandler<FAccelByteModelsGetGroupListResponse>::CreateLambda([](const FAccelByteModelsGetGroupListResponse& Result)
{
// Do something if GetGroupList succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupList fails
}));
string groupName = "YourGroupName";
string groupRegion = "US";
int limit = 100;
int offset = 0;
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().SearchGroups(groupName, groupRegion, limit, offset, result =>
{
if (result.IsError)
{
// Do something if SearchGroups fails
Debug.Log($"Error SearchGroups, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if SearchGroups succeeds
});
Retrieve group information by group ID
To give more clear information about the group to the players, you can use the following function to get information about a group by using the group ID:
- Unreal Engine
- Unity
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.GetGroup(GroupId, THandler<FAccelByteModelsGroupInformation>::CreateLambda([](const FAccelByteModelsGroupInformation& Result)
{
// Do something if GetGroup succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroup fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().GetGroup(groupId, result =>
{
if (result.IsError)
{
// Do something if GetGroup fails
Debug.Log($"Error GetGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetGroup succeeds
});
Retrieve group information by user ID
You can let your players get their group information by using their user Id with the following function:
If the player you requested doesn't belong to any group, the returned status will be ErrorCode.UserNotBelongToAnyGroup
, and the player will be able to be invited to a group.
- Unreal Engine
- Unity
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
ApiClient->Group.GetUserGroupInfoByUserId(UserId, THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateLambda([](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if GetUserGroupInfoByUserId succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserGroupInfoByUserId fails
}));
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().GetMyGroupInfo(result =>
{
if (result.IsError)
{
// Do something if GetMyGroupInfo fails
Debug.Log($"Error GetMyGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetMyGroupInfo succeeds
})
Retrieve a player's group information
You can allow your player to retrieve the group information of the user with a specific user Id.
- Unreal Engine
- Unity
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
ApiClient->Group.GetUserGroupInfoByUserId(UserId, THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateLambda([](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if GetUserGroupInfoByUserId succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserGroupInfoByUserId fails
}));
string userId = "YourUserId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().GetOtherGroupInfo(userId, result =>
{
if (result.IsError)
{
// Do something if GetOtherGroupInfo fails
Debug.Log($"Error GetOtherGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetOtherGroupInfo succeeds
});
Retrieve a group's member list
You can let your players retrieve a list of members within a specific group. Use the following function to get a group's member list by using a group Id.
- Unreal Engine
- Unity
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
FAccelByteModelsGetGroupMembersListByGroupIdRequest RequestContent = {};
RequestContent.Limit = 100;
RequestContent.Offset = 0;
RequestContent.SortBy = EAccelByteGroupListSortBy::ASCENDING;
ApiClient->Group.GetGroupMembersListByGroupId(GroupId, RequestContent, THandler<FAccelByteModelsGetGroupMemberListResponse>::CreateLambda([](const FAccelByteModelsGetGroupMemberListResponse& Result)
{
// Do something if GetGroupMembersListByGroupId succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupMembersListByGroupId fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().GetGroupMemberList(groupId, result =>
{
if (result.IsError)
{
// Do something if GetGroupMemberList fails
Debug.Log($"Error GetGroupMemberList, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetGroupMemberList succeeds
});
Interact with groups
The follow sections details players' interactions with groups.
Join a group
Players can request to join OPEN or PUBLIC groups. Each group type will have a different behavior:
- OPEN groups will allow players to automatically join.
- PUBLIC groups will require players to make a join request which needs to be approved by a group admin before the player can join.
Use the following function to allow players join to a specific group.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.JoinGroup(GroupId, THandler<FAccelByteModelsJoinGroupResponse>::CreateLambda([](const FAccelByteModelsJoinGroupResponse& Result)
{
// Do something if JoinGroup succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if JoinGroup fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().JoinGroup(groupId, result =>
{
if (result.IsError)
{
// Do something if JoinGroup fails
Debug.Log($"Error JoinGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if JoinGroup succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.JoinV2Group(GroupId, THandler<FAccelByteModelsJoinGroupResponse>::CreateLambda([](const FAccelByteModelsJoinGroupResponse& Result)
{
// Do something if JoinV2Group succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if JoinV2Group fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().JoinGroupV2(groupId, result =>
{
if (result.IsError)
{
// Do something if JoinGroupV2 fails
Debug.Log($"Error JoinGroupV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if JoinGroupV2 succeeds
});
Cancel a join request
After a player requests to join a PUBLIC group, that request can be canceled.
- Unreal Engine
- Unity
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.CancelJoinGroupRequest(GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if CancelJoinGroupRequest succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CancelJoinGroupRequest fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().CancelJoinGroupRequest(groupId, result =>
{
if (result.IsError)
{
// Do something if JoinGroupV2 fails
Debug.Log($"Error JoinGroupV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if JoinGroupV2 succeeds
});
Leave a group
To allow players to leave a group, you can use the following function:
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
ApiClient->Group.LeaveGroup(THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if LeaveGroup succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if LeaveGroup fails
}));
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().LeaveGroup(result =>
{
if (result.IsError)
{
// Do something if LeaveGroup fails
Debug.Log($"Error LeaveGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if LeaveGroup succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.LeaveV2Group(GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if LeaveV2Group succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if LeaveV2Group fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().LeaveGroupV2(groupId, result =>
{
if (result.IsError)
{
// Do something if LeaveGroupV2 fails
Debug.Log($"Error LeaveGroupV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if LeaveGroupV2 succeeds
});
Invite a player to a group
Group admins can 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 V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
ApiClient->Group.InviteUserToGroup(UserId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if InviteUserToGroup succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if InviteUserToGroup fails
}));
string userId = "YourUserId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().InviteOtherUserToGroup(userId, result =>
{
if (result.IsError)
{
// Do something if InviteOtherUserToGroup fails
Debug.Log($"Error InviteOtherUserToGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if InviteOtherUserToGroup succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
FString GroupId = "YourGroupId";
ApiClient->Group.InviteUserToV2Group(UserId, GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if InviteUserToV2Group succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if InviteUserToV2Group fails
}));
string userId = "YourUserId";
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().InviteOtherUserToGroupV2(userId, groupId, result =>
{
if (result.IsError)
{
// Do something if InviteOtherUserToGroupV2 fails
Debug.Log($"Error InviteOtherUserToGroupV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if InviteOtherUserToGroupV2 succeeds
});
Remove/kick a group member
Group admins can also remove (kick) group members from the group.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
ApiClient->Group.KickGroupMember(UserId, THandler<FAccelByteModelsKickGroupMemberResponse>::CreateLambda([](const FAccelByteModelsKickGroupMemberResponse& Result)
{
// Do something if KickGroupMember succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if KickGroupMember fails
}));
string userId = "YourUserId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().KickGroupMember(userId, result =>
{
if (result.IsError)
{
// Do something if KickGroupMember fails
Debug.Log($"Error KickGroupMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if KickGroupMember succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
FString GroupId = "YourGroupId";
ApiClient->Group.KickV2GroupMember(UserId, GroupId, THandler<FAccelByteModelsKickGroupMemberResponse>::CreateLambda([](const FAccelByteModelsKickGroupMemberResponse& Result)
{
// Do something if KickV2GroupMember succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if KickV2GroupMember fails
}));
string userId = "YourUserId";
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().KickGroupMemberV2(userId, groupId, result =>
{
if (result.IsError)
{
// Do something if KickGroupMemberV2 fails
Debug.Log($"Error KickGroupMemberV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if KickGroupMemberV2 succeeds
});
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
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FAccelByteModelsLimitOffsetRequest RequestContent = {};
RequestContent.Limit = 100;
RequestContent.Offset = 0;
ApiClient->Group.GetGroupInvitationRequests(RequestContent, THandler<FAccelByteModelsGetMemberRequestsListResponse>::CreateLambda([](const FAccelByteModelsGetMemberRequestsListResponse& Result)
{
// Do something if GetGroupInvitationRequests succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupInvitationRequests fails
}));
int limit = 100;
int offset = 0;
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().GetGroupInvitationRequests(limit, offset, result =>
{
if (result.IsError)
{
// Do something if GetGroupInvitationRequests fails
Debug.Log($"Error GetGroupInvitationRequests, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetGroupInvitationRequests succeeds
});
Accept a group invitation request
After getting the invitation list, players can accept an invitation.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.AcceptGroupInvitation(GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if AcceptGroupInvitation succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AcceptGroupInvitation fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().AcceptGroupInvitation(groupId, result =>
{
if (result.IsError)
{
// Do something if AcceptGroupInvitation fails
Debug.Log($"Error AcceptGroupInvitation, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if AcceptGroupInvitation succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.AcceptGroupInvitation(GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if AcceptGroupInvitation succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AcceptGroupInvitation fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().AcceptGroupInvitationV2(groupId, result =>
{
if (result.IsError)
{
// Do something if AcceptGroupInvitationV2 fails
Debug.Log($"Error AcceptGroupInvitationV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if AcceptGroupInvitationV2 succeeds
});
Reject a group invitation request
Players can reject any invitation request.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.RejectGroupInvitation(GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if RejectGroupInvitation succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if RejectGroupInvitation fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().RejectGroupInvitation(groupId, result =>
{
if (result.IsError)
{
// Do something if RejectGroupInvitation fails
Debug.Log($"Error RejectGroupInvitation, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if RejectGroupInvitation succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
ApiClient->Group.RejectV2GroupInvitation(GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if RejectV2GroupInvitation succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if RejectV2GroupInvitation fails
}));
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().RejectGroupInvitationV2(groupId, result =>
{
if (result.IsError)
{
// Do something if RejectGroupInvitationV2 fails
Debug.Log($"Error RejectGroupInvitationV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if RejectGroupInvitationV2 succeeds
});
Get a list of group member join requests
Group admins can get a list of group member join requests to either approve or reject them.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
FAccelByteModelsLimitOffsetRequest RequestContent = {};
RequestContent.Limit = 100;
RequestContent.Offset = 0;
ApiClient->Group.GetGroupJoinRequests(GroupId, RequestContent, THandler<FAccelByteModelsGetMemberRequestsListResponse>::CreateLambda([](const FAccelByteModelsGetMemberRequestsListResponse& Result)
{
// Do something if GetGroupJoinRequests succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupJoinRequests fails
}));
string groupId = "YourGroupId";
int limit = 100;
int offset = 0;
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().GetGroupJoinRequests(groupId, limit, offset, result =>
{
if (result.IsError)
{
// Do something if GetGroupJoinRequests fails
Debug.Log($"Error GetGroupJoinRequests, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetGroupJoinRequests succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString GroupId = "YourGroupId";
FAccelByteModelsLimitOffsetRequest RequestContent = {};
RequestContent.Limit = 100;
RequestContent.Offset = 0;
ApiClient->Group.GetGroupJoinRequestList(GroupId, RequestContent, THandler<FAccelByteModelsGetMemberRequestsListResponse>::CreateLambda([](const FAccelByteModelsGetMemberRequestsListResponse& Result)
{
// Do something if GetGroupJoinRequestList succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupJoinRequestList fails
}));
string groupId = "YourGroupId";
int limit = 100;
int offset = 0;
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().GetGroupJoinRequestsV2(groupId, limit, offset, result =>
{
if (result.IsError)
{
// Do something if GetGroupJoinRequestsV2 fails
Debug.Log($"Error GetGroupJoinRequestsV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetGroupJoinRequestsV2 succeeds
});
Accept a group member join request
After getting the list of join requests, a group admin can accept them to the group.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
ApiClient->Group.AcceptGroupJoinRequest(UserId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if AcceptGroupJoinRequest succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AcceptGroupJoinRequest fails
}));
string userId = "YourUserId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().AcceptOtherJoinRequest(userId, result =>
{
if (result.IsError)
{
// Do something if AcceptOtherJoinRequest fails
Debug.Log($"Error AcceptOtherJoinRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if AcceptOtherJoinRequest succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
FString GroupId = "YourGroupId";
ApiClient->Group.AcceptV2GroupJoinRequest(UserId, GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if AcceptV2GroupJoinRequest succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AcceptV2GroupJoinRequest fails
}));
string userId = "YourUserId";
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().AcceptOtherJoinRequestV2(userId, groupId, result =>
{
if (result.IsError)
{
// Do something if AcceptOtherJoinRequestV2 fails
Debug.Log($"Error AcceptOtherJoinRequestV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if AcceptOtherJoinRequestV2 succeeds
});
Reject a group member join request
Group admins can reject any member join request.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
ApiClient->Group.RejectGroupJoinRequest(UserId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if RejectGroupJoinRequest succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if RejectGroupJoinRequest fails
}));
string userId = "YourUserId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().RejectOtherJoinRequest(userId, result =>
{
if (result.IsError)
{
// Do something if RejectOtherJoinRequest fails
Debug.Log($"Error RejectOtherJoinRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if RejectOtherJoinRequest succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString UserId = "YourUserId";
FString GroupId = "YourGroupId";
ApiClient->Group.RejectV2GroupJoinRequest(UserId, GroupId, THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateLambda([](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if RejectV2GroupJoinRequest succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if RejectV2GroupJoinRequest fails
}));
string userId = "YourUserId";
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().RejectOtherJoinRequestV2(userId, groupId, result =>
{
if (result.IsError)
{
// Do something if RejectOtherJoinRequestV2 fails
Debug.Log($"Error RejectOtherJoinRequestV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if RejectOtherJoinRequestV2 succeeds
});
Manage 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 or kicking a member, among others. Every group member will be automatically assigned to the default member role that is already defined in the group configuration. This can either be an admin group role or a member group role.
Get a list of group member roles
An admin can get a list of the member roles that have already been created in the AGS Admin Portal.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FAccelByteModelsLimitOffsetRequest RequestContent = {};
RequestContent.Limit = 100;
RequestContent.Offset = 0;
ApiClient->Group.GetMemberRoles(RequestContent, THandler<FAccelByteModelsGetMemberRolesListResponse>::CreateLambda([](const FAccelByteModelsGetMemberRolesListResponse& Result)
{
// Do something if GetMemberRoles succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetMemberRoles fails
}));
int limit = 100;
int offset = 0;
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().GetMemberRoles(limit, offset, result =>
{
if (result.IsError)
{
// Do something if GetMemberRoles fails
Debug.Log($"Error GetMemberRoles, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetMemberRoles succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FAccelByteModelsLimitOffsetRequest RequestContent = {};
RequestContent.Limit = 100;
RequestContent.Offset = 0;
ApiClient->Group.GetAllMemberRoles(RequestContent, THandler<FAccelByteModelsGetMemberRolesListResponse>::CreateLambda([](const FAccelByteModelsGetMemberRolesListResponse& Result)
{
// Do something if GetAllMemberRoles succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetAllMemberRoles fails
}));
Promote a member to a role
A group admin can promote a group member to a specific role if the role has been defined for that group.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString MemberRoleId = "YourMemberRoleId";
FAccelByteModelsUserIdWrapper RequestContent = {};
RequestContent.UserId = "YourUserId";
ApiClient->Group.AssignMemberRole(MemberRoleId, RequestContent, THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateLambda([](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if AssignMemberRole succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AssignMemberRole fails
}));
string memberRoleId = "YourMemberRoleId";
string userId = "YourUserId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().AssignRoleToMember(memberRoleId, userId, result =>
{
if (result.IsError)
{
// Do something if AssignRoleToMember fails
Debug.Log($"Error AssignRoleToMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if AssignRoleToMember succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString MemberRoleId = "YourMemberRoleId";
FString GroupId = "YourGroupId";
FAccelByteModelsUserIdWrapper RequestContent = {};
RequestContent.UserId = "YourUserId";
ApiClient->Group.AssignV2MemberRole(MemberRoleId, GroupId, RequestContent, THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateLambda([](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if AssignV2MemberRole succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AssignV2MemberRole fails
}));
string memberRoleId = "YourMemberRoleId";
string userId = "YourUserId";
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().AssignRoleToMemberV2(memberRoleId, userId, groupId, result =>
{
if (result.IsError)
{
// Do something if AssignRoleToMemberV2 fails
Debug.Log($"Error AssignRoleToMemberV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if AssignRoleToMemberV2 succeeds
});
Remove a member's role
An admin can remove a role from a member.
- Unreal Engine V1
- Unity V1
- Unreal Engine V2
- Unity V2
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString MemberRoleId = "YourMemberRoleId";
FAccelByteModelsUserIdWrapper RequestContent = {};
RequestContent.UserId = "YourUserId";
ApiClient->Group.DeleteMemberRole(MemberRoleId, RequestContent, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteMemberRole succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteMemberRole fails
}));
string memberRoleId = "YourMemberRoleId";
string userId = "YourUserId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().RemoveRoleFromMember(memberRoleId, userId, result =>
{
if (result.IsError)
{
// Do something if RemoveRoleFromMember fails
Debug.Log($"Error RemoveRoleFromMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if RemoveRoleFromMember succeeds
});
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString MemberRoleId = "YourMemberRoleId";
FString GroupId = "YourGroupId";
FAccelByteModelsUserIdWrapper RequestContent = {};
RequestContent.UserId = "YourUserId";
ApiClient->Group.DeleteV2MemberRole(MemberRoleId, GroupId, RequestContent, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteV2MemberRole succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteV2MemberRole fails
}));
string memberRoleId = "YourMemberRoleId";
string userId = "YourUserId";
string groupId = "YourGroupId";
AccelByteSDK.GetClientRegistry().GetApi().GetGroup().RemoveRoleFromMemberV2(memberRoleId, userId, groupId, result =>
{
if (result.IsError)
{
// Do something if RemoveRoleFromMemberV2 fails
Debug.Log($"Error RemoveRoleFromMemberV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if RemoveRoleFromMemberV2 succeeds
});
Manage group notifications
Some group activities 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 SetMessageNotifDelegate
and the OnNotification
functions.
- Unreal Engine
- Unity
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
ApiClient->Lobby.Connect();
FString NotificationTopic = "group";
ApiClient->Lobby.SetMessageNotifDelegate(AccelByte::Api::Lobby::FMessageNotif::CreateLambda([&](FAccelByteModelsNotificationMessage const& Notif)
{
if (Notif.Topic == NotificationTopic)
{
// Do something if there's a new notification under group topic
}
}));
AccelByteSDK.GetClientRegistry().GetApi().GetLobby().Connect();
string notificationTopic = "group";
AccelByteSDK.GetClientRegistry().GetApi().GetLobby().OnNotification += result =>
{
if (result.IsError)
{
// Do something if OnNotification fails
Debug.Log($"Error OnNotification, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
if (result.Value.topic == notificationTopic)
{
// Do something if there's a new notification under group topic
}
};
Notify a player of a group invitation
Here's an example of the payload for a notification sent to a player when they've been invited to join a group:
- Group Invitation Notification
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"kind": "invitation"
}
Notify a player of an accepted join request
Here's an example of the payload for a notification sent to a player when their request to join a group has been accepted:
- Group Acceptance Notification
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"kind": "accepted-request"
}
Notify a player of a rejected join request
Here's an example of the payload for a notification sent to a player when their request to join a group has been rejected:
- Group Rejection Notifications
{
"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:
- New Group Member Notifications
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMember",
"kind": "new-member"
}
Notify a group admin of a request to join a group
Here's an example of the payload for a notification sent to group admins when a player has requested to join their group:
- Member Request Notifications
{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMember",
"kind": "join-request"
}
Notify a player of a new role assignment
Here's an example of the payload for a notification sent to a player when a group admin has assigned a role to them:
- Member Role Assignment Notifications
{
"groupName": "nameofgroup",
"groupId": "groupId",
"roleName": "Chief",
"roleId": "roleId",
"kind": "assigned-role"
}
Notify a member of a role removal
Here's an example of the payload for a notification sent to a player when a group admin has removed a role from them:
- Member Role Removal Notifications
{
"groupName": "nameofgroup",
"groupId": "groupId",
"roleName": "Chief",
"roleId": "roleId",
"kind": "removed-role"
}