Last Updated: 6/15/2022, 11:15:59 AM

# Session Browser

# Overview

AccelByte offers a session browser feature to store your game session data. This browser supports P2P sessions to store game clients and a Dedicated Server to store game server sessions. Both P2P and Dedicated Server sessions use REST API for the game client and server.

# P2P

P2P sessions are generated by a game client and act as a session host. P2P entries contain game client session data which are stored in the session browser. When the lobby is disconnected, the P2P entries are removed from the server. If the lobby connection is reconnected by the host, past P2P entries will not be listed in the server browser and must be recreated in the session browser.

# Dedicated Server (DS)

A Dedicated Server session is a session generated by the server that is managed by Armada.

  • If the server is managed by Armada, the Session browser will listen to events broadcast from our Dedicated Server Manager Controller (DSMC) and Matchmaking service. The game’s Dedicated Server (DS) only needs to interact with those services, and so the data in the session browser is automatically updated.
  • If the server is not managed by Armada, we provide REST APIs in our SDK so the DS session can also be managed via the session browser, even if the DS is not managed with Armada.

# Permissions

Permissions are used to grant access to specific resources within our services. Make sure your account has the following permissions before you attempt to manage the Session Browser.

Usage Resource Action
Create Session NAMESPACE:{namespace}:SESSIONBROWSER:SESSION Create
Retrieve List of Game Sessions ADMIN:NAMESPACE:{namespace}:SESSIONBROWSER:SESSION Read
Retrieve Game Session by Session ID ADMIN:NAMESPACE:{namespace}:SESSIONBROWSER:SESSION Read
Update Session NAMESPACE:{namespace}:SESSIONBROWSER:SESSION Update
Delete Session NAMESPACE:{namespace}:SESSIONBROWSER:SESSION Delete
Join Session NAMESPACE:{namespace}:SESSIONBROWSER:SESSION Read
Register Player to Session NAMESPACE:{namespace}:SESSIONBROWSER:SESSION Update
Unregister Player to Session NAMESPACE:{namespace}:SESSIONBROWSER:SESSION Update
Get Recent Player Data NAMESPACE:{namespace}:SESSIONBROWSER:RECENTPLAYER Read

Permissions work slightly differently depending on whether they are assigned to IAM Clients or on Roles assigned to users. For more information, see AccelByte’s Authentication and Authorization documentation.

# Prerequisites

  • Make sure you’ve downloaded and configured AccelByte’s Unreal Engine SDK.
  • Log in as a user in Game Client if you want to implement a session browser in the game client.
  • Log in with game client credentials if you want to implement a session browser in the game server.

# Call the Session Browser

# Game Client

You can call the session browser from the Game Client using the following function:

FApiClientPtr ApiClient { FMultiRegistry::GetApiClient() };
ApiClient->SessionBrowser

# Game Server (Dedicated Server)

You can call the session browser from the Dedicated Server using the following function:

FServerApiClientPtr ServerApiClient{ FMultiRegistry::GetServerApiClient() };

ServerApiClient->ServerSessionBrowser

# Implementing Session Browser with the SDK

# Create a Session

Call the CreateGameSession() function to create a new session. Make sure you specify the EAccelByteSessionType parameter as dedicated if you want to create a Dedicated Server session, or p2p to create a P2P session.

# Retrieve a List of Game Sessions

Call the SessionBrowser.GetGameSessions() function to retrieve a list of active game sessions. Make sure you specify the EAccelByteSessionType parameter as dedicated if you want to retrieve a list of Dedicated Server sessions, or p2p to list P2P sessions.

# Retrieve a Game Session by Session ID

Call the SessionBrowser.GetGameSessions() function to retrieve a specific game session. Make sure you specify the EAccelByteSessionType parameter as dedicated if you want to retrieve a Dedicated Server session, or p2p to list P2P sessions.

# Update a Session

Call the UpdateGameSession() function to keep the ongoing session’s player count updated in real-time.

# Delete a Session

Call the RemoveGameSession() function to delete a session.

# Join a Session

Call the JoinSession() function to join a known session. This method requires a session ID and password (if the session has a password). This function will return network data such as IP and Port that can be used to connect to a game host.

# Register Player to Session

When the game host detects that a player has joined a session, the RegisterPlayer() function will be called to update the session data with the new player.

# Unregister Player to Session

When the game host detects that a player has left a session, the UnegisterPlayer() function will be called to remove the player from the session data.

# Get Recent Player Data

Call the GeRecentPlayer() function to retrieve information such as userID and displayName from recently encountered players.

# Connecting Custom Services to the Session Browser using the Server SDK

# SDK Initialization

Before using the Session Browser service, you must initialize your server-side SDK to be authorized to perform create, read, update, and delete actions.

# Golang SDK Initialization

To start using the Session Browser service from the Golang SDK, you must initialize the SDK by completing the following steps:

  • Create your OAuth Client and assign the necessary permissions to access the Achievement service.

  • Log in as a Client using the SDK.

  • Initialize the service using the following function:

    sessionService := &sessionbrowser.SessionService{
      Client:          factory.NewSessionBrowserClient(&repository.ConfigRepositoryImpl{}),
      TokenRepository: &repository.TokenRepositoryImpl{},
    }
    

Once you have successfully completed this initialization, you can use the Golang SDK to create, read, update, and delete Session Browsers from your serverless app.

# Python SDK Initialization

To start using the Session Browser service from the Python SDK, you must initialize the SDK by completing the following steps:

Once you have successfully completed this initialization, you can use the Python SDK to create, read, update, and delete Session Browsers from your serverless app.

# .NET (C#) SDK Initialization

Before using the Session Browser service, you will need to set some permissions. Use the following .NET namespaces:

using AccelByte.Sdk.Api.Sessionbrowser.Model;
using AccelByte.Sdk.Api.Sessionbrowser.Operation;
using AccelByte.Sdk.Api.Sessionbrowser.Wrapper;

# Java SDK Initialization

Before using the Session Browser service, you will need to set some permissions. Initialize the Session wrapper from the Session Browser service using the following code:

Session wSBSession = new Session(sdk);

Once completed, you can use the SDK to create, read, update, or delete sessions.

# Register a New Game Session

Use the following function to create a session (opens new window):

# Delete a Session

Use the following function to delete a session (opens new window) using the session ID:

# Retrieve a Session

Use the following function to retrieve a session (opens new window) using the session ID:

# Update a Session

Use the following function to update a session (opens new window). You can update a game session when you need to update the maximum number of players or number of current players in a session.