Not translated yet — showing English.
Server Events
Your servers push typed events to players; the game listens for them with PlayServEvents.Subscribe<T>. A game server or a cloud function sends an event to a group, and every player in that group gets it over the connection the SDK already keeps open. Events go one way: from your servers to the game.
using System;
using Playserv.Wrapper;
using UnityEngine;
[Serializable]
public class MatchFinished
{
public string WinnerCallsign;
public int Score;
}
public sealed class MatchEvents : MonoBehaviour
{
IDisposable _sub;
async void Start()
{
await PlayServEvents.SubscribeGroupAsync("arena-7");
_sub = PlayServEvents.Subscribe<MatchFinished>(e => Debug.Log($"{e.WinnerCallsign} wins with {e.Score}"));
}
void OnDestroy() => _sub?.Dispose();
}
How delivery works
| Part | What it does |
|---|---|
| The event type | A plain [Serializable] C# class with public fields. No base class. |
| The group | A named channel. A player gets events sent to the groups their game joined with SubscribeGroupAsync, and nothing else. |
| The sender | Your game server or cloud function, which sends an event to a group. |
| The handler | Subscribe<T> picks the events of type T out of everything the game receives. |
An event is matched by its type name: the sender names the event type, and the game delivers it to the subscribers of the class with that name. Use the same class name on both sides. The namespace may differ only if no other class the game subscribes to has the same name.
Events aren't stored
An event reaches the players who are in the group when it is sent. A player who joins later, or is offline at that moment, doesn't get it. For state a player must see, use records and send an event only to say something happened.
Subscribe
| Call | What it does |
|---|---|
PlayServEvents.Subscribe<T>(handler) | Calls handler for every event of type T. Returns an IDisposable: dispose it to stop. |
PlayServEvents.SubscribeGroupAsync(name) | Joins a group, so its events reach this game. |
PlayServEvents.UnsubscribeGroupAsync(name) | Leaves a group. |
Call them after PlayServ.Connect(): subscribing before the game is connected throws InvalidOperationException. Several handlers of one type share one subscription.
After a reconnect, the SDK joins the game's groups again and keeps its handlers, with no code on your side. Events sent while the game was disconnected are not delivered.
Groups, their names and limits are covered in Groups.
Who sends events
| Sender | Call |
|---|---|
| A Unity Dedicated Server | PlayServGameServer.Events.PublishAsync(group, eventType, payload), with the group's project-scoped name, see Groups. |
| A C# cloud function | Platform.Publish<T>(group, payload), which uses the C# type's name as the event type. |
The game can't send events
PlayServEvents.Publish, PublishForGroup and PublishForUser are in the SDK but always throw PlayServEventPublishingException. So do the Send… helpers the Editor generates for [Event] types. To make something happen for other players, call a function or your game server, and let it send the event.
Limits
| What | Limit |
|---|---|
| Groups per connection | 64 |
| Group name | Up to 256 characters, including the project prefix PlayServ adds |
| Event size | 1 MiB |
| Joining or leaving a group | 10 seconds, then TimeoutException |
Errors
| Error | When |
|---|---|
PlayServGroupSubscriptionException | A group join was refused: UnifiedError.SourceCode is group_subscription_limit_reached or group_outside_project. Retrying won't help. |
TimeoutException | The platform didn't answer a group join or leave within 10 seconds. |
PlayServEventPublishingException | The game tried to send an event. |
An event that can't be read as T is logged and dropped; other events keep arriving.
Next steps
- Groups — the channels events are sent to
- Cloud Functions & RPC — ask your server to do something
- Game Server Hosting — send events from a Unity game server
Last updated on 22 Oct 2026