Skip to main content

Introduction to session data management with Session Manager

Last updated on October 7, 2024

Introduction

AccelByte Game Services (AGS) allows you to customize the session data during the session (party and game sessions) created, updated, and deleted events using an Extend Override app.

Session Manager Actions

When triggering an Extend Override app, the Session service will give the following input parameters:

  • Previous session state
  • Current session state
  • Operation (On game and party Created, Updated, Deleted)

The app will return the session data on the Session Create operation when there's a modification to the session data.

Prerequisites

Contract functions

The following are the functions in the contract:

service SessionManager {
rpc OnSessionCreated(SessionCreatedRequest) returns (SessionResponse);
rpc OnSessionUpdated(SessionUpdatedRequest) returns (google.protobuf.Empty);
rpc OnSessionDeleted(SessionDeletedRequest) returns (google.protobuf.Empty);
rpc OnPartyCreated(PartyCreatedRequest) returns (PartyResponse);
rpc OnPartyUpdated(PartyUpdatedRequest) returns (google.protobuf.Empty);
rpc OnPartyDeleted(PartyDeletedRequest) returns (google.protobuf.Empty);
}

OnSessionCreated​

OnSessionCreated is called when a game session is created and you want customize its data before the session is returned to the client. This operation is called synchronously, so the Session service will wait for the response from the gRPC server before storing the data in the database.

In the app template, the following function can be found in pkg/server/grpcserver.go.

func (s *SessionManager) OnSessionCreated(ctx context.Context, request *sessionmanager.SessionCreatedRequest) (*sessionmanager.SessionResponse, error) {
...
}

OnSessionUpdated

OnSessionUpdated is called when there is an update or modification to the game session. This operation is asynchronous, so the Session service will notify the gRPC server if there is any update on the game session and will not wait for the response to update the database.

In the app template, the following function can be found in pkg/server/grpcserver.go.

func (s *SessionManager) OnSessionUpdated(ctx context.Context, request *sessionmanager.SessionUpdatedRequest) (*emptypb.Empty, error) {
...
}

OnSessionDeleted

OnSessionDeleted is called when the game session is being deleted. This event is asynchronous, so the session service will notify the gRPC server if there is any delete request and will not wait for the response to update the database.

In the app template, the following function can be found in pkg/server/grpcserver.go.

func (s *SessionManager) OnSessionDeleted(ctx context.Context, request *sessionmanager.SessionDeletedRequest) (*emptypb.Empty, error) {
...
}

OnPartyCreated​

OnPartyCreated is called when a party session is created and you want customize its data before the session is returned to the client. This operation is called synchronously, so the Session service will wait for the response from the gRPC server before storing the data in the database.

In the app template, the following function can be found in pkg/server/grpcserver.go.

func (s *SessionManager) OnPartyCreated(ctx context.Context, request *sessionmanager.PartyCreatedRequest) (*sessionmanager.PartyResponse, error) {
...
}

OnPartyUpdated

OnPartyUpdated is called when there is an update or modification to the party session. This operation is asynchronous, so the Session service will notify the gRPC server if there is any update on the party session and will not wait for the response to update the database.

In the app template, the following function can be found in pkg/server/grpcserver.go.

func (s *SessionManager) OnPartyUpdated(ctx context.Context, request *sessionmanager.PartyUpdatedRequest) (*emptypb.Empty, error) {
...
}

OnPartyDeleted

OnPartyDeleted is called when the party session is being deleted. This event is asynchronous, so the session service will notify the gRPC server if there is any delete request and will not wait for the response to update the database.

In the app template, the following function can be found in pkg/server/grpcserver.go.

func (s *SessionManager) OnPartyDeleted(ctx context.Context, request *sessionmanager.PartyDeletedRequest) (*emptypb.Empty, error) {
...
}