Skip to main content

Group Interactions

Last updated on

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.

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
}));

Cancel Join Request

After a player requests to join a group, that request can be canceled.

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
}));

Leave a Group

To leave a group, you can use this function.

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
}));

Invite a Player to 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.

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
}));

Kick a Group Member

Group admins can also kick group members out of the group.

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
}));

Get a List of Group Invitation Requests

Players can get the list of group invitation requests, to either accept or reject these invitations.

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
}));

Accept Group Invitation Request

After getting the invitation list, players can accept an invitation.

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
}));

Reject Group Invitation Request

Players can also reject any invitation request.

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
}));

Get List of Group Member Join Requests

Group admins can get the list of group member join requests, to either approve or reject them.

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
}));

Accept Group Member Join Request

After getting the list of join requests, a group admin can accept them to the group.

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
}));

Reject Group Member Join Request

Group admin can also reject any member join request.

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
}));

Get Bulk Users' Presence

You can use this endpoint to get users' presence information in bulk.

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
}));