Skip to main content

Handle Multiple Events

Last updated on June 17, 2026

Overview

An Extend Event Handler app is a gRPC server. AccelByte Gaming Services (AGS) emits events to Kafka, and the Extend platform delivers each event to your app by calling a gRPC method.

A single Extend Event Handler app can handle as many events as you want. For each event you care about, you:

  1. Include its Protocol Buffers (Protobuf) definition.
  2. Implement the gRPC service that the proto generates.
  3. Register that service with the gRPC server.

There is no special router to configure. Every AGS event maps to its own gRPC service with a single OnMessage RPC, so implementing more services simply means your one app responds to more events. The pattern works identically across Go, Java, Python, and C#. Only the language mechanics differ.

For background, see Get started with Extend Event Handler app template and Create your own Extend Event Handler app.

How event delivery works

Each AGS event is described in a .proto file as a service with one RPC. The message — for example, UserLoggedIn — carries the event payload.

// One service per event. The message (for example, UserLoggedIn) carries the payload.
service UserAuthenticationUserLoggedInService {
rpc OnMessage(UserLoggedIn) returns (google.protobuf.Empty);
}

service UserAuthenticationUserLoggedOutService {
rpc OnMessage(UserLoggedOut) returns (google.protobuf.Empty);
}

The AccelByte event spec proto files (covering account, auth, and user events as well as many other domains) are published in the accelbyte-api-proto repository. When AGS produces a userLoggedIn event, the Extend platform invokes UserAuthenticationUserLoggedInService/OnMessage on your app. If you have implemented and registered that service, your code runs. If you have not, the event is simply not handled.

The recipe to handle multiple events is always the same three steps:

  1. Add the proto for each event you want, then regenerate the code.
  2. Implement the generated service by writing the OnMessage handler.
  3. Register the service with the gRPC server.

The reference apps ship with UserLoggedIn (and UserThirdPartyLoggedIn) already implemented as examples. You extend the same pattern for every additional event.

Add, implement, and register a service

The steps below show how to apply the three-step pattern in each language. As an example, they add a handler for the userLoggedOut event alongside the existing login handlers.

Reference: extend-event-handler-csharp

  1. Add the proto and reference it. Place the proto under Protos/iam/account/v1/ (or the appropriate path), then reference it in the .csproj file so it generates on build.

    <ItemGroup>
    <Protobuf Include="Protos\iam\account\v1\account.proto" GrpcServices="Server" />
    </ItemGroup>
  2. Implement the service in Services/. Extend the generated ...ServiceBase and override OnMessage.

    // Services/UserLoggedOutService.cs
    public class UserLoggedOutService
    : UserAuthenticationUserLoggedOutService.UserAuthenticationUserLoggedOutServiceBase
    {
    private readonly ILogger<UserLoggedOutService> _Logger;

    public UserLoggedOutService(ILogger<UserLoggedOutService> logger,
    IAccelByteServiceProvider abProvider)
    {
    _Logger = logger;
    }

    public override Task<Empty> OnMessage(UserLoggedOut request, ServerCallContext context)
    {
    _Logger.LogInformation("Received UserLoggedOut event: {@Request}", request);
    // ... your custom logic ...
    return Task.FromResult(new Empty());
    }
    }
  3. Register the service in Program.cs with another MapGrpcService<T>() call.

    app.MapGrpcService<UserLoggedInService>();
    app.MapGrpcService<UserThirdPartyLoggedInService>();
    app.MapGrpcService<UserLoggedOutService>(); // <-- your new handler

Each additional event is one new service class plus one more MapGrpcService<T>() call.

Test multiple events locally

All reference apps expose gRPC reflection and run on port 6565 by default, so you can test each handler with a gRPC client such as Postman.

  1. Connect to localhost:6565 with plaintext and reflection enabled.
  2. From the method dropdown, pick the service you want to test, for example UserAuthenticationUserLoggedInService/OnMessage or UserAuthenticationUserLoggedOutService/OnMessage.
  3. Send a sample event payload as JSON, including fields such as namespace and userId.
  4. Confirm that a successful call returns an empty response (google.protobuf.Empty).

Repeat for each event to confirm that every registered handler responds. Once deployed, AGS routes real events to the matching service automatically.