Server Messaging
Overview
// Server Messaging can only be used on game servers. Calls made on the client will fail.
if (!Game.IsServer()) return;
// Subscribe to a topic to receive messages
const subscription = Platform.Server.Messaging.Subscribe("player-events", (data) => {
print("Received message:", data);
});
// Publish a message to all subscribers of a topic
Platform.Server.Messaging.Publish("player-events", {
event: "player-joined",
userId: "12345",
serverName: "Battle Arena 1"
}).then((result) => {
if (result.success) {
print("Message published successfully");
}
});
// Unsubscribe when no longer needed
subscription.unsubscribe();
// Alternatively, if you are using a Bin to manage resources,
// the subscription can be added directly to it.
// this.bin.Add(subscription);Use Cases
API Reference
Subscribe
Publish
Topic Names
Common Patterns
Global Event Broadcasting
Cross-Server Player Tracking
Periodic Status Updates
Best Practices
Limitations
Last updated