MultiConnectMultiConnectDocs Website home
MultiConnectSDK › Developer Guide

11. Master Server Communication

When using a distributed architecture (separate Master and Game Servers), you may need to send data from Game Server rooms to the Master Server.

Server Room to Master Server

Script 11.1: MyGameRoom

public class MyGameRoom : IRoom
{
    private Room room;
    
    public void OnRoomCreated(Room room)
    {
        this.room = room;
        
        // Listen for messages from master server
        room.AddResponseListener(MasterMessage.TournamentUpdate, OnTournamentUpdate);
    }
    
    void NotifyMasterServer(object data)
    {
        // Send data to master server
        room.SendMcBinaryToMasterServer(data, MasterMessage.RoomStatusUpdate, McProtocol.Reliable);
    }
    
    void OnTournamentUpdate(object obj)
    {
        // Handle message from master server
        var update = (TournamentData)obj;
        Debug.Log($"Tournament update received: {update.tournamentId}");
    }

    // ...plus the other IRoom methods, as in the Quick Start.
}

public enum MasterMessage
{
    RoomStatusUpdate = 1000,
    TournamentUpdate = 1001,
    GlobalAnnouncement = 1002
}

[McSerializationObject]
public class TournamentData
{
    public string tournamentId;
    public string status;
}

Note: Direct client-to-master communication is only available through room APIs. For global client operations (like getting server status), implement custom listeners on your Master Server.