MultiConnectMultiConnectDocs Website home
MultiConnectSDK › AI Agent Guide

6. API reference

Client

Call What it does
Client.ConnectToServer(ServerRegions.Any, playerId) Connects through MultiConnectCloud. Empty playerId generates one
McHosting.ConnectToBestRegionAsync(playerId) Connects to the lowest-ping region
McHosting.ServerBuild = "1.0.0.8" (or the client's Server Build field) Connects to that server build, kept running for older clients; empty means the latest. A retired build fails the connect with McHosting.ServerBuildUnavailable true, so show "update required"; it never falls back to the latest
Client.onMasterServerConnected, Client.onMasterServerDisConnected Connection events
Client.DisconnectFromServer() Disconnects
Client.MyID This player's id
GameRooms.FindRoom(parameters, maxPlayers, minPlayers) Matchmaking
GameRooms.CreateJoinPrivateRoom(parameters, maxPlayers, minPlayers, RoomID: id, RoomPassword: pw, SpectatorCnt: n) Joins a private room, creating it if needed
GameRooms.JoinPrivateRoom(roomId, password) Joins a private room
GameRooms.JoinAsSpectator(roomId, spectatorId, password) Watches a room
GameRooms.OnRoomJoined, OnPrivateRoomJoined, OnSpectatorRoomJoined A room was joined. Each hands you the Room
GameRooms.OnRoomJoinedFailed, OnPrivateRoomJoinedFailed, OnSpectatorRoomJoinedFailed It failed: (string message, int code)
room.SendMcBinary(obj, type, protocol) Sends to the server's room
room.AddResponseListener(type, handler) Listens in this room
room.LeaveRoom() Leaves the room
Client.SendDataToMaster(obj, type, protocol) Sends to the master, outside a room

Server room

Room here is MultiConnect.Server.Room, handed to IRoom.OnRoomCreated.

Call What it does
room.AddResponseListener(type, handler) Listens for a client message
room.SendMcBinaryToAll(obj, type, protocol) Sends to everyone in the room
room.SendMcBinaryTo(playerId, obj, type, protocol) Sends to one player
room.SendMcBinaryToSpectator(id, obj, type, protocol) Sends to one spectator
room.SendMcBinaryToMasterServer(obj, type) Sends to the master
room.isOpen = false Stops new players joining. Do this when a match starts
room.LeaveRoom(playerId, msg) Removes a player
room.DestroyRoom() Ends the room
room.roomId, room.parameters, room.roomPass The room's details
MasterServer.CreateRoom(parameters, maxPlayers, minPlayers, timeToDestroy, removePlayerTime, roomId) The master creates an empty room
MasterServer.AddResponseListener, GameServer.AddResponseListener Listens outside a room
MasterServer.SendDataTo(playerId, obj, type, protocol) Sends to one player, outside a room

Hosting

Call What it does
McHostingEnvironment.IsHosted, Role, Region, DeploymentId, PublicHost Where this server is running
McHostingEnvironment.BuildNumber This server's build number (MC_BUILD_NUMBER), e.g. 1.0.0.8
McHostingEnvironment.PortOr(7777) The port to listen on
McAnalytics.Track(name, properties) Records a custom event, shown under Game Analytics