セッションマネージャによるセッションデータ管理の紹介
Introduction
AccelByte Gaming 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.
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
- An environment with AGS version 3.78 and later.
- A Google Cloud Platform (GCP) account.
- An understanding of the following AGS components:
API Contract
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.
- C#
- Go
- Java
- Python
public override Task<SessionResponse> OnSessionCreated(SessionCreatedRequest request, ServerCallContext context)
{
...
}
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) {
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/session/sessionmanager/service/SessionManagerImplementation.java
.
@Override
public void onSessionCreated(SessionCreatedRequest request, StreamObserver<SessionResponse> responseObserver) {
...
}
In the app template, the following function can be found in src/app/services/session_manager.py
.
async def OnSessionCreated(self, request: SessionCreatedRequest, context: Any) -> SessionResponse:
...
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.
- C#
- Go
- Java
- Python
public override Task<Empty> OnSessionUpdated(SessionUpdatedRequest request, ServerCallContext context)
{
...
}
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) {
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/session/sessionmanager/service/SessionManagerImplementation.java
.
@Override
public void onSessionUpdated(SessionUpdatedRequest request, StreamObserver<Empty> responseObserver) {
...
}
In the app template, the following function can be found in src/app/services/session_manager.py
.
async def OnSessionUpdated(self, request: SessionUpdatedRequest, context: Any) -> Empty:
...
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.
- C#
- Go
- Java
- Python
public override Task<Empty> OnSessionDeleted(SessionDeletedRequest request, ServerCallContext context)
{
...
}
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) {
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/session/sessionmanager/service/SessionManagerImplementation.java
.
public void onSessionDeleted(SessionDeletedRequest request, StreamObserver<Empty> responseObserver) {
...
}
In the app template, the following function can be found in src/app/services/session_manager.py
.
async def OnSessionDeleted(self, request: SessionDeletedRequest, context: Any) -> Empty:
...
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.
- C#
- Go
- Java
- Python
public override Task<PartyResponse> OnPartyCreated(PartyCreatedRequest request, ServerCallContext context)
{
...
}
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) {
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/session/sessionmanager/service/SessionManagerImplementation.java
.
@Override
public void onPartyCreated(PartyCreatedRequest request, StreamObserver<PartyResponse> responseObserver) {
...
}
In the app template, the following function can be found in src/app/services/session_manager.py
.
async def OnPartyCreated(self, request: PartyCreatedRequest, context: Any) -> PartyResponse:
...
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.
- C#
- Go
- Java
- Python
public override Task<Empty> OnPartyUpdated(PartyUpdatedRequest request, ServerCallContext context)
{
...
}
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) {
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/session/sessionmanager/service/SessionManagerImplementation.java
.
@Override
public void onPartyUpdated(PartyUpdatedRequest request, StreamObserver<Empty> responseObserver) {
...
}
In the app template, the following function can be found in src/app/services/session_manager.py
.
async def OnPartyUpdated(self, request: PartyUpdatedRequest, context: Any) -> Empty:
...
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.
- C#
- Go
- Java
- Python
public override Task<Empty> OnPartyDeleted(PartyDeletedRequest request, ServerCallContext context)
{
...
}
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) {
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/session/sessionmanager/service/SessionManagerImplementation.java
.
@Override
public void onPartyDeleted(PartyDeletedRequest request, StreamObserver<Empty> responseObserver) {
...
}
In the app template, the following function can be found in src/app/services/session_manager.py
.
async def OnPartyDeleted(self, request: PartyDeletedRequest, context: Any) -> Empty:
...
You could find more information about gRPC request handling here.