Last Updated: 10/13/2021, 11:47:39 PM

# Presence

# Overview

AccelByte Presence services enable players to see what other players are doing. Presence services can show players if their friends are online or offline, and if they’re available to play together. We use WebSocket to ensure that a player’s presence status is updated in real-time. These services include two main features:

  • Set User Presence allows clients to set a player’s availability and activity. There are four availability status options: Offline, Available, Busy, and Invisible. Activity status is customizable and can include Playing Game A, In Lobby, In Match, or In Party Looking For Members.
  • Get Friend Presence allows clients to show players what their friends are doing. Clients can display a player’s availability and activity status to their friends, so that players can invite friends that aren’t busy to play together.

If the service is successful, when a client sets a player’s availability code and status the that status will be visible to that player’s friends.

# Implementing Presence using the SDK

# Create a Status and View a Friend’s Status

A player’s presence can be set by a game, or by Player Portal or Launcher. This allows the player’s friends to see when the player is online and what they are doing.

# Get a List of Friends’ Statuses

Players can also see a list of all of their friends’ statuses.

# Bulk Friends Presence

Retrieve player’s presence information in bulk. This will also count the number of users based on their presence status, such as online, busy, invisible, or offline. You can also set the countOnly parameter to true to fetch the count without fetching the users’ account data.

# Managing Presence using the API

# Query Users Presence

You can query all users' presence using the API. To do so, follow the steps below:

  1. Use the Query Users Presence: GET - /lobby/v1/public/presence/namespaces/{namespace}/users/presence endpoint.
  2. Input the Game Namespace.
  3. Input the User ID. Separate the value with comma to input more than one user ID.
  4. Select the countOnly value. Select true if you want to display the number of each availability status.

Upon a successful request, the leaderboards will be retrieved. Here is the response example of the successful request: