-
Notifications
You must be signed in to change notification settings - Fork 0
realtime
The Realtime module is the core of the extension: it connects to the Photon Cloud, joins matchmaking lobbies and rooms, and sends and receives events between players. Player and room custom properties have their own modules (Realtime Player Properties and Realtime Room Properties), and connection diagnostics live in Realtime Peer.
Note
After connecting you must call photon_realtime_service every step for the client to send and receive.
Initialise, connect, and service the client:
- photon_realtime_init
- photon_realtime_shutdown
- photon_realtime_service
- photon_realtime_connect
- photon_realtime_disconnect
- photon_realtime_select_region
- photon_realtime_reconnect_and_rejoin
- photon_realtime_fetch_server_timestamp
Join lobbies, and create, join and leave rooms:
- photon_realtime_operation_join_lobby
- photon_realtime_operation_leave_lobby
- photon_realtime_operation_create_room
- photon_realtime_operation_join_or_create_room
- photon_realtime_operation_join_room
- photon_realtime_operation_join_random_room
- photon_realtime_operation_join_random_or_create_room
- photon_realtime_operation_leave_room
- photon_realtime_operation_get_room_list
- photon_realtime_operation_lobby_stats
- photon_realtime_operation_find_friends
- photon_realtime_operation_web_rpc
- photon_realtime_operation_change_groups
- photon_realtime_operation_custom_auth_next_step
Raise custom events and read buffered binary events:
- photon_realtime_operation_raise_event_string
- photon_realtime_operation_raise_event_buffer
- photon_realtime_get_buffer_event_queue_count
- photon_realtime_clear_buffer_event_queue
- photon_realtime_peek_next_buffer_event_size
- photon_realtime_peek_next_buffer_event_code
- photon_realtime_peek_next_buffer_event_player_number
- photon_realtime_receive_one_event_buffer
Query connection and room state:
- photon_realtime_is_initialized
- photon_realtime_is_connected
- photon_realtime_is_in_game_room
- photon_realtime_is_in_room
- photon_realtime_is_in_lobby
- photon_realtime_get_current_room_name
- photon_realtime_get_local_player_number
- photon_realtime_get_server_time_offset
- photon_realtime_get_server_time
- photon_realtime_get_bytes_in
- photon_realtime_get_bytes_out
- photon_realtime_get_state
- photon_realtime_get_round_trip_time
- photon_realtime_get_round_trip_time_variance
- photon_realtime_get_disconnected_cause
- photon_realtime_get_user_id
- photon_realtime_get_count_players_ingame
- photon_realtime_get_count_games_running
- photon_realtime_get_count_players_online
- photon_realtime_get_master_server_address
- photon_realtime_get_region
- photon_realtime_get_region_with_best_ping
- photon_realtime_get_friend_list_age
Tune connection behaviour:
- photon_realtime_get_disconnect_timeout
- photon_realtime_set_disconnect_timeout
- photon_realtime_get_ping_interval
- photon_realtime_set_ping_interval
- photon_realtime_get_auto_join_lobby
- photon_realtime_set_auto_join_lobby
Query the current room and its players:
- photon_realtime_get_room_player_count
- photon_realtime_get_room_max_players
- photon_realtime_get_room_is_open
- photon_realtime_get_room_is_visible
- photon_realtime_get_master_client_number
- photon_realtime_set_master_client
- photon_realtime_get_room_list_count
- photon_realtime_get_room_info_by_index
- photon_realtime_get_player_count
- photon_realtime_get_player_number_by_index
- photon_realtime_player_get_name
- photon_realtime_player_get_user_id
- photon_realtime_player_is_inactive
- photon_realtime_player_is_master_client
- photon_realtime_get_player_numbers
Register and remove the event callbacks:
- photon_realtime_set_callback_debug
- photon_realtime_set_callback_connected
- photon_realtime_set_callback_disconnected
- photon_realtime_set_callback_connection_error
- photon_realtime_set_callback_client_error
- photon_realtime_set_callback_server_error
- photon_realtime_set_callback_warning
- photon_realtime_set_callback_join_room_event
- photon_realtime_set_callback_leave_room_event
- photon_realtime_set_callback_custom_event
- photon_realtime_set_callback_player_properties_change
- photon_realtime_set_callback_room_properties_change
- photon_realtime_set_callback_room_list_update
- photon_realtime_set_callback_app_stats_update
- photon_realtime_set_callback_lobby_stats_update
- photon_realtime_set_callback_cache_slice_changed
- photon_realtime_set_callback_master_client_changed
- photon_realtime_set_callback_properties_change_failed
- photon_realtime_set_callback_custom_authentication_step
- photon_realtime_set_callback_available_regions
- photon_realtime_set_callback_secret_receival
- photon_realtime_set_callback_direct_connection_established
- photon_realtime_set_callback_direct_connection_failed
- photon_realtime_set_callback_direct_message
- photon_realtime_set_callback_custom_operation_response
- photon_realtime_remove_callback_debug
- photon_realtime_remove_callback_connected
- photon_realtime_remove_callback_disconnected
- photon_realtime_remove_callback_connection_error
- photon_realtime_remove_callback_client_error
- photon_realtime_remove_callback_server_error
- photon_realtime_remove_callback_warning
- photon_realtime_remove_callback_join_room_event
- photon_realtime_remove_callback_leave_room_event
- photon_realtime_remove_callback_custom_event
- photon_realtime_remove_callback_player_properties_change
- photon_realtime_remove_callback_room_properties_change
- photon_realtime_remove_callback_room_list_update
- photon_realtime_remove_callback_app_stats_update
- photon_realtime_remove_callback_lobby_stats_update
- photon_realtime_remove_callback_cache_slice_changed
- photon_realtime_remove_callback_master_client_changed
- photon_realtime_remove_callback_properties_change_failed
- photon_realtime_remove_callback_custom_authentication_step
- photon_realtime_remove_callback_available_regions
- photon_realtime_remove_callback_secret_receival
- photon_realtime_remove_callback_direct_connection_established
- photon_realtime_remove_callback_direct_connection_failed
- photon_realtime_remove_callback_direct_message
- photon_realtime_remove_callback_custom_operation_response
The Realtime module uses the following structs:
- PhotonRealtimeConnectOptions
- PhotonRealtimeAuthenticationValues
- PhotonRealtimeRoomOptions
- PhotonRealtimeJoinRoomOptions
- PhotonRealtimeJoinRandomOptions
- PhotonRealtimeRaiseEventOptions
- PhotonRealtimeEventBufferReceived
- PhotonRealtimeRoomInfo
- PhotonRealtimeFriendInfo
- PhotonRealtimeLobbyStats
The Realtime module defines the following constants:
- PhotonRealtimeState
- PhotonRealtimeDisconnectCause
- PhotonRealtimeAppErrorCode
- PhotonRealtimeLobbyType
- PhotonRealtimeMatchmakingMode
- PhotonRealtimeReceiverGroup
- PhotonRealtimeEventCache
- PhotonRealtimeCustomAuthType
- PhotonRealtimeDirectMode
- PhotonRealtimeRegionSelectionMode
- PhotonRealtimeServerType
- PhotonRealtimeLBOperationCode
- PhotonRealtimeLBEventCode
Initialises the Realtime client. Call this once before any other Realtime function.
Syntax:
photon_realtime_init()
Returns:
Whether initialisation succeeded.
Shuts the Realtime client down and releases its resources. Call photon_realtime_disconnect first if still connected.
Syntax:
photon_realtime_shutdown()
Returns:
Whether the client was shut down.
Dispatches queued incoming and outgoing traffic for the Realtime client. This must be called every step while connected, otherwise the client neither sends nor receives.
Syntax:
photon_realtime_service()
Returns:
Whether the client was serviced.
Connects to the Photon Cloud using the given Application ID and application version. The App ID identifies your Photon Realtime application; the version string keeps incompatible client builds apart. The result is delivered to the photon_realtime_set_callback_connected callback.
Syntax:
photon_realtime_connect(app_id, app_version, options=undefined)
| Argument | Type | Description |
|---|---|---|
| app_id | String | Your Photon Realtime Application ID. |
| app_version | String | A version string of your choosing for your game build. |
| options | PhotonRealtimeConnectOptions | Optional connection options. |
Returns:
Whether the connection attempt started.
Example:
var _app_id = extension_get_option_value("GMPhoton", "appIdRealtime");
photon_realtime_connect(_app_id, "1.0", new PhotonRealtimeConnectOptions());Disconnects the Realtime client from the Photon Cloud. The photon_realtime_set_callback_disconnected callback fires once the disconnect completes.
Syntax:
photon_realtime_disconnect()
Returns:
Whether the disconnect started.
Selects the Photon Cloud region to connect to (for example "eu", "us", "asia"). Call before connecting, or in response to photon_realtime_set_callback_available_regions.
Syntax:
photon_realtime_select_region(region)
| Argument | Type | Description |
|---|---|---|
| region | String | The region token to use. |
Returns:
Whether the region was selected.
Attempts to reconnect to the last game server and rejoin the room the client was previously in. Useful for recovering from a temporary disconnect.
Syntax:
photon_realtime_reconnect_and_rejoin()
Returns:
Whether the reconnect attempt started.
Requests the current server timestamp. Once available it can be read with photon_realtime_get_server_time.
Syntax:
photon_realtime_fetch_server_timestamp()
Returns:
Whether the request was sent.
Joins a matchmaking lobby. While in a lobby the client receives room-list and lobby-stats updates.
Syntax:
photon_realtime_operation_join_lobby(lobby_name, lobby_type, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| lobby_name | String | The name of the lobby to join. |
| lobby_type | PhotonRealtimeLobbyType | The lobby type. |
| callback | Function | Optional callback invoked with no arguments when the join completes. |
Returns:
Whether the operation was sent.
Leaves the current matchmaking lobby.
Syntax:
photon_realtime_operation_leave_lobby(callback=undefined)
| Argument | Type | Description |
|---|---|---|
| callback | Function | Optional callback invoked with no arguments when the operation completes. |
Returns:
Whether the operation was sent.
Creates a new room and joins it. Fails if a room with the same name already exists.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_create_room(room_name, options, custom_properties, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| room_name | String | The name of the room to create. |
| options | PhotonRealtimeRoomOptions | The room configuration. |
| custom_properties | Struct | Custom room properties as a GML struct. |
| callback | Function | Optional callback invoked with the operation result. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | PhotonRealtimeAppErrorCode | The operation result code (Ok on success). |
| error_string | String | A human-readable result message. |
| room_name | String | The name of the room that was created. |
| local_player_number | Real | The local player's actor number in the room. |
Example:
var _opts = new PhotonRealtimeRoomOptions();
_opts.max_players = 4;
photon_realtime_operation_create_room("arena", _opts, { map: "desert" }, function(_error_code, _error_string, _room_name, _player_number) {
if (_error_code == PhotonRealtimeAppErrorCode.Ok) show_debug_message($"Created {_room_name}");
});Joins the named room, creating it with the given options if it does not yet exist.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_join_or_create_room(room_name, options, custom_properties, cache_slice_index=undefined, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| room_name | String | The name of the room to join or create. |
| options | PhotonRealtimeRoomOptions | The room configuration used if the room is created. |
| custom_properties | Struct | Custom room properties as a GML struct (used on creation). |
| cache_slice_index | Real | Optional event-cache slice index to fetch on join. |
| callback | Function | Optional callback invoked with the operation result. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | PhotonRealtimeAppErrorCode | The operation result code (Ok on success). |
| error_string | String | A human-readable result message. |
| room_name | String | The name of the room that was joined or created. |
| local_player_number | Real | The local player's actor number in the room. |
Joins an existing room by name.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_join_room(room_name, options, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| room_name | String | The name of the room to join. |
| options | PhotonRealtimeJoinRoomOptions | The join options. |
| callback | Function | Optional callback invoked with the operation result. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | PhotonRealtimeAppErrorCode | The operation result code (Ok on success). |
| error_string | String | A human-readable result message. |
| room_name | String | The name of the room that was joined. |
| local_player_number | Real | The local player's actor number in the room. |
Joins a random room matching the given criteria and expected properties.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_join_random_room(options, expected_properties, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| options | PhotonRealtimeJoinRandomOptions | The matchmaking options. |
| expected_properties | Struct | Custom properties a room must match, as a GML struct. |
| callback | Function | Optional callback invoked with the operation result. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | PhotonRealtimeAppErrorCode | The operation result code (Ok on success; NoMatchFound if no room matched). |
| error_string | String | A human-readable result message. |
| room_name | String | The name of the room that was joined. |
| local_player_number | Real | The local player's actor number in the room. |
Leaves the current room.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_leave_room(will_come_back, send_authentication_cookie, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| will_come_back | Boolean | If true, the player stays as an inactive actor so they can rejoin later. |
| send_authentication_cookie | Boolean | Whether to send the authentication cookie with the request. |
| callback | Function | Optional callback invoked with the operation result. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | PhotonRealtimeAppErrorCode | The operation result code (Ok on success). |
| error_string | String | A human-readable result message. |
Attempts to join a random room matching the criteria, creating a new room with the given options if none is found.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_join_random_or_create_room(room_name, options, custom_properties, random_options, expected_properties, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| room_name | String | The name to use if a room is created. |
| options | PhotonRealtimeRoomOptions | The room configuration used if a room is created. |
| custom_properties | Struct | Custom room properties as a GML struct (used on creation). |
| random_options | PhotonRealtimeJoinRandomOptions | The random-matchmaking options. |
| expected_properties | Struct | Custom properties a room must match, as a GML struct. |
| callback | Function | Optional callback invoked with the operation result. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | PhotonRealtimeAppErrorCode | The operation result code (Ok on success). |
| error_string | String | A human-readable result message. |
| room_name | String | The name of the room that was joined or created. |
| local_player_number | Real | The local player's actor number in the room. |
Requests a room list from a specific SQL lobby.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_get_room_list(lobby_name, sql_filter, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| lobby_name | String | The lobby to query. |
| sql_filter | String | An SQL-style filter string. |
| callback | Function | Optional callback invoked with the room list. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| rooms | Array of PhotonRealtimeRoomInfo | The rooms that were added or updated. |
| removed | Array of String | The names of rooms that were removed. |
Requests lobby statistics for all tracked lobbies.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_lobby_stats(callback=undefined)
| Argument | Type | Description |
|---|---|---|
| callback | Function | Optional callback invoked with the lobby stats. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| stats | Array of PhotonRealtimeLobbyStats | The statistics for each tracked lobby. |
Finds friends by user ID.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_find_friends(friends, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| friends | Array of String | An array of user IDs to look up. |
| callback | Function | Optional callback invoked with the friend info. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| friends | Array of PhotonRealtimeFriendInfo | The status of each requested friend. |
Calls a WebRPC endpoint configured for your Photon application.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_operation_web_rpc(uri_path, callback=undefined)
| Argument | Type | Description |
|---|---|---|
| uri_path | String | The WebRPC path to call. |
| callback | Function | Optional callback invoked with the response. |
Returns:
Whether the operation was sent.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | Real | The operation result code. |
| error_string | String | A human-readable result message. |
| uri_path | String | The WebRPC path that was called. |
| result_code | Real | The result code returned by the WebRPC service. |
| response_data | Struct | The response data returned by the service, as a GML struct. |
Changes the interest groups this client receives events from. Pass the groups to remove and the groups to add; an empty or omitted array leaves that set unchanged.
Syntax:
photon_realtime_operation_change_groups(groups_to_remove=undefined, groups_to_add=undefined)
| Argument | Type | Description |
|---|---|---|
| groups_to_remove | Array of Real | The interest groups to stop receiving. |
| groups_to_add | Array of Real | The interest groups to start receiving. |
Returns:
Whether the operation was sent.
Sends additional data for a multi-step custom authentication flow. Call this from inside the photon_realtime_set_callback_custom_authentication_step callback.
Syntax:
photon_realtime_operation_custom_auth_next_step(authentication)
| Argument | Type | Description |
|---|---|---|
| authentication | PhotonRealtimeAuthenticationValues | The next-step authentication values. |
Returns:
Whether the operation was sent.
Raises a custom event carrying a string payload to other players in the room. Receivers get it via photon_realtime_set_callback_custom_event.
Syntax:
photon_realtime_operation_raise_event_string(reliable, payload, event_code, options=undefined)
| Argument | Type | Description |
|---|---|---|
| reliable | Boolean | Whether the event is sent reliably. |
| payload | String | The string payload to send. |
| event_code | Real | A custom event code identifying the event. |
| options | PhotonRealtimeRaiseEventOptions | Optional targeting and caching options. |
Returns:
Whether the event was raised.
Example:
photon_realtime_operation_raise_event_string(true, "hello", 1);Raises a custom event carrying a binary buffer payload to other players in the room. Receivers are notified via photon_realtime_set_callback_custom_event (with is_buffer set) and read the bytes with photon_realtime_receive_one_event_buffer.
Syntax:
photon_realtime_operation_raise_event_buffer(reliable, data, bytes, event_code, options=undefined)
| Argument | Type | Description |
|---|---|---|
| reliable | Boolean | Whether the event is sent reliably. |
| data | Buffer | The buffer holding the payload. |
| bytes | Real | The number of bytes from the buffer to send. |
| event_code | Real | A custom event code identifying the event. |
| options | PhotonRealtimeRaiseEventOptions | Optional targeting and caching options. |
Returns:
Whether the event was raised.
Returns the number of buffered binary events waiting to be read from the queue.
Syntax:
photon_realtime_get_buffer_event_queue_count()
Returns:
The number of queued buffer events.
Clears all buffered binary events from the queue without reading them.
Syntax:
photon_realtime_clear_buffer_event_queue()
Returns:
Whether the queue was cleared.
Returns the size in bytes of the next buffered binary event without removing it from the queue.
Syntax:
photon_realtime_peek_next_buffer_event_size()
Returns:
The size of the next event in bytes.
Returns the event code of the next buffered binary event without removing it from the queue.
Syntax:
photon_realtime_peek_next_buffer_event_code()
Returns:
The event code of the next event.
Removes the next buffered binary event from the queue and writes its payload into the given buffer.
Syntax:
photon_realtime_receive_one_event_buffer(out_data, max_bytes, offset)
| Argument | Type | Description |
|---|---|---|
| out_data | Buffer | The buffer to write the payload into. |
| max_bytes | Real | The maximum number of bytes to write. |
| offset | Real | The offset within the buffer to start writing at. |
Returns:
A struct describing the received event.
Example:
while (photon_realtime_get_buffer_event_queue_count() > 0) {
var _size = photon_realtime_peek_next_buffer_event_size();
var _buf = buffer_create(_size, buffer_grow, 1);
var _info = photon_realtime_receive_one_event_buffer(_buf, _size, 0);
if (_info.ok) {
// read from _buf ... (event_code _info.event_code, from player _info.player_number)
}
buffer_delete(_buf);
}Returns whether the Realtime client has been initialised.
Syntax:
photon_realtime_is_initialized()
Returns:
Whether the client is initialised.
Returns whether the client is currently connected to the Photon Cloud.
Syntax:
photon_realtime_is_connected()
Returns:
Whether the client is connected.
Returns whether the client is connected to a game server and inside a room.
Syntax:
photon_realtime_is_in_game_room()
Returns:
Whether the client is in a game room.
Returns whether the client is currently in a room.
Syntax:
photon_realtime_is_in_room()
Returns:
Whether the client is in a room.
Returns whether the client is currently in a matchmaking lobby.
Syntax:
photon_realtime_is_in_lobby()
Returns:
Whether the client is in a lobby.
Returns the name of the room the client is currently in, or an empty string if not in a room.
Syntax:
photon_realtime_get_current_room_name()
Returns:
The current room name.
Returns the local player's actor number within the current room.
Syntax:
photon_realtime_get_local_player_number()
Returns:
The local player number.
Returns the offset between local time and server time, in milliseconds.
Syntax:
photon_realtime_get_server_time_offset()
Returns:
The server time offset in milliseconds.
Returns the current server time in milliseconds.
Syntax:
photon_realtime_get_server_time()
Returns:
The server time in milliseconds.
Returns the total number of bytes received by the client.
Syntax:
photon_realtime_get_bytes_in()
Returns:
The number of bytes received.
Returns the total number of bytes sent by the client.
Syntax:
photon_realtime_get_bytes_out()
Returns:
The number of bytes sent.
Returns the current client state.
Syntax:
photon_realtime_get_state()
Returns:
The current state.
Returns the current round-trip time to the server, in milliseconds.
Syntax:
photon_realtime_get_round_trip_time()
Returns:
The round-trip time in milliseconds.
Returns the variance of the round-trip time to the server, in milliseconds.
Syntax:
photon_realtime_get_round_trip_time_variance()
Returns:
The round-trip time variance.
Returns the cause of the most recent disconnect.
Syntax:
photon_realtime_get_disconnected_cause()
Returns:
The disconnect cause.
Returns the local player's user ID.
Syntax:
photon_realtime_get_user_id()
Returns:
The local user ID.
Returns the number of players currently in games across the application. Available after connecting and while receiving app stats.
Syntax:
photon_realtime_get_count_players_ingame()
Returns:
The number of players in games.
Returns the number of games (rooms) currently running across the application.
Syntax:
photon_realtime_get_count_games_running()
Returns:
The number of running games.
Returns the total number of players currently online across the application.
Syntax:
photon_realtime_get_count_players_online()
Returns:
The number of players online.
Returns the address of the master server the client is using.
Syntax:
photon_realtime_get_master_server_address()
Returns:
The master server address.
Returns the region token the client is currently connected to.
Syntax:
photon_realtime_get_region()
Returns:
The current region.
Returns the region with the best measured ping, available after the available-regions ping check completes.
Syntax:
photon_realtime_get_region_with_best_ping()
Returns:
The best-ping region token.
Returns the age in milliseconds of the last friend-list result from photon_realtime_operation_find_friends.
Syntax:
photon_realtime_get_friend_list_age()
Returns:
The friend list age in milliseconds.
Returns the disconnect timeout in milliseconds.
Syntax:
photon_realtime_get_disconnect_timeout()
Returns:
The disconnect timeout.
Sets the disconnect timeout: how long without a response before the client considers itself disconnected.
Syntax:
photon_realtime_set_disconnect_timeout(milliseconds)
| Argument | Type | Description |
|---|---|---|
| milliseconds | Real | The timeout in milliseconds. |
Returns:
Whether the value was set.
Returns the interval in milliseconds between pings sent to the server.
Syntax:
photon_realtime_get_ping_interval()
Returns:
The ping interval.
Sets the interval in milliseconds between pings sent to the server.
Syntax:
photon_realtime_set_ping_interval(milliseconds)
| Argument | Type | Description |
|---|---|---|
| milliseconds | Real | The ping interval in milliseconds. |
Returns:
Whether the value was set.
Returns whether the client automatically joins the default lobby after connecting.
Syntax:
photon_realtime_get_auto_join_lobby()
Returns:
Whether auto-join-lobby is enabled.
Sets whether the client automatically joins the default lobby after connecting.
Syntax:
photon_realtime_set_auto_join_lobby(enabled)
| Argument | Type | Description |
|---|---|---|
| enabled | Boolean | Whether to auto-join the lobby. |
Returns:
Whether the value was set.
Returns the number of players currently in the room.
Syntax:
photon_realtime_get_room_player_count()
Returns:
The room player count.
Returns the maximum number of players allowed in the current room.
Syntax:
photon_realtime_get_room_max_players()
Returns:
The room's maximum players.
Returns whether the current room is open to new players.
Syntax:
photon_realtime_get_room_is_open()
Returns:
Whether the room is open.
Returns whether the current room is visible in the lobby room list.
Syntax:
photon_realtime_get_room_is_visible()
Returns:
Whether the room is visible.
Returns the player number of the current room's master client.
Syntax:
photon_realtime_get_master_client_number()
Returns:
The master client's player number.
Assigns the master client role to the given player. Only the current master client may do this.
Syntax:
photon_realtime_set_master_client(player_number)
| Argument | Type | Description |
|---|---|---|
| player_number | Real | The player number to make master client. |
Returns:
Whether the request was sent.
Returns the number of rooms in the most recent lobby room list.
Syntax:
photon_realtime_get_room_list_count()
Returns:
The number of rooms.
Returns information about a room in the lobby room list by index.
Syntax:
photon_realtime_get_room_info_by_index(index)
| Argument | Type | Description |
|---|---|---|
| index | Real | The zero-based index into the room list. |
Returns:
The room information.
Returns the number of players currently tracked in the room.
Syntax:
photon_realtime_get_player_count()
Returns:
The player count.
Returns the player number at the given index in the room's player list.
Syntax:
photon_realtime_get_player_number_by_index(index)
| Argument | Type | Description |
|---|---|---|
| index | Real | The zero-based index into the player list. |
Returns:
The player number.
Returns the display name of the given player.
Syntax:
photon_realtime_player_get_name(player_number)
| Argument | Type | Description |
|---|---|---|
| player_number | Real | The player number. |
Returns:
The player's name.
Returns the user ID of the given player.
Syntax:
photon_realtime_player_get_user_id(player_number)
| Argument | Type | Description |
|---|---|---|
| player_number | Real | The player number. |
Returns:
The player's user ID.
Returns whether the given player is currently inactive (has left but may rejoin).
Syntax:
photon_realtime_player_is_inactive(player_number)
| Argument | Type | Description |
|---|---|---|
| player_number | Real | The player number. |
Returns:
Whether the player is inactive.
Returns whether the given player is the room's master client.
Syntax:
photon_realtime_player_is_master_client(player_number)
| Argument | Type | Description |
|---|---|---|
| player_number | Real | The player number. |
Returns:
Whether the player is the master client.
Returns an array of the player numbers currently in the room.
Syntax:
photon_realtime_get_player_numbers()
Returns:
An array of player numbers.
Registers the callback fired with SDK debug output.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_debug(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call with debug output. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| debug_level | Real | The debug level of the message. |
| message | String | The debug message. |
Registers the callback fired when the client finishes connecting.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_connected(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on connect. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | PhotonRealtimeAppErrorCode | The connect result code (Ok on success). |
| error_string | String | A human-readable result message. |
| region | String | The region that was connected to. |
Registers the callback fired when the client has disconnected. The callback takes no arguments.
Syntax:
photon_realtime_set_callback_disconnected(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on disconnect. |
Returns:
Whether the callback was set.
Registers the callback fired on a low-level connection error.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_connection_error(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a connection error. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | Real | The connection error code. |
Registers the callback fired on a client-side error.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_client_error(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a client error. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | Real | The client error code. |
Registers the callback fired on a server-reported error.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_server_error(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a server error. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| error_code | Real | The server error code. |
Registers the callback fired on a client warning.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_warning(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a warning. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| warning_code | Real | The warning code. |
Registers the callback fired when a player joins the room. When the local client joins, it fires once per player already present.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_join_room_event(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a join event. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| joining_player_number | Real | The player number that triggered the join. |
| player_number | Real | The player number described by this call. |
| player_name | String | The player's display name. |
| user_id | String | The player's user ID. |
| is_inactive | Boolean | Whether the player is inactive. |
| is_master_client | Boolean | Whether the player is the master client. |
Registers the callback fired when a player leaves the room.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_leave_room_event(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a leave event. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| player_number | Real | The player number that left. |
| is_inactive | Boolean | Whether the player became inactive (may rejoin) rather than leaving for good. |
Registers the callback fired when a custom event raised by photon_realtime_operation_raise_event_string or photon_realtime_operation_raise_event_buffer is received.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_custom_event(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a custom event. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| player_number | Real | The sender's player number. |
| event_code | Real | The custom event code. |
| payload | String | The string payload; empty for buffer events (read the bytes with photon_realtime_receive_one_event_buffer). |
| is_buffer | Boolean | Whether the event carries a binary buffer payload. |
Registers the callback fired when the room's custom properties change. See Realtime Room Properties.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_room_properties_change(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a room-properties change. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| properties | Struct | The changed properties, as a GML struct. |
Registers the callback fired when a player's custom properties change. See Realtime Player Properties.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_player_properties_change(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a player-properties change. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| player_number | Real | The player whose properties changed. |
| properties | Struct | The changed properties, as a GML struct. |
Registers the callback fired when the lobby room list updates. The callback takes no arguments; read the updated list with photon_realtime_get_room_list_count and photon_realtime_get_room_info_by_index.
Syntax:
photon_realtime_set_callback_room_list_update(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a room-list update. |
Returns:
Whether the callback was set.
Registers the callback fired when application statistics update. The callback takes no arguments; read the values with photon_realtime_get_count_players_online, photon_realtime_get_count_players_ingame and photon_realtime_get_count_games_running.
Syntax:
photon_realtime_set_callback_app_stats_update(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on an app-stats update. |
Returns:
Whether the callback was set.
Registers the callback fired with lobby statistics updates.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_lobby_stats_update(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a lobby-stats update. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| stats | Array of PhotonRealtimeLobbyStats | The statistics for each tracked lobby. |
Registers the callback fired when the active event-cache slice index changes.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_cache_slice_changed(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a cache-slice change. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| cache_slice_index | Real | The new active cache slice index. |
Registers the callback fired when the room's master client changes.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_master_client_changed(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a master-client change. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| player_number | Real | The player number of the new master client. |
| old_player_number | Real | The player number of the previous master client. |
Registers the callback fired when a properties change (for example a compare-and-swap) is rejected by the server. The callback takes no arguments.
Syntax:
photon_realtime_set_callback_properties_change_failed(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a failed properties change. |
Returns:
Whether the callback was set.
Registers the callback fired during a multi-step custom authentication flow. Respond with photon_realtime_operation_custom_auth_next_step.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_custom_authentication_step(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call for each authentication step. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| response_data | Struct | The intermediate authentication response data, as a GML struct. |
Registers the callback fired when the list of available regions arrives. Use it to pick a region with photon_realtime_select_region.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_available_regions(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call with the available regions. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| regions | Array of String | The available region tokens. |
| servers | Array of String | The server address for each region. |
Registers the callback fired when the client receives an authentication secret from the server.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_secret_receival(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on secret receival. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| secret | String | The authentication secret. |
Registers the callback fired when a direct (peer-to-peer) connection to another player is established.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_direct_connection_established(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call when a direct connection is established. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| remote_peer_id | Real | The peer ID of the remote player. |
Registers the callback fired when a direct (peer-to-peer) connection attempt fails.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_direct_connection_failed(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call when a direct connection fails. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| remote_peer_id | Real | The peer ID of the remote player. |
Registers the callback fired when a message arrives over a direct (peer-to-peer) connection.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_direct_message(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a direct message. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| remote_peer_id | Real | The peer ID of the sender. |
| relay_fallback | Boolean | Whether the message was relayed through the server rather than sent directly. |
| message | String | The message payload. |
Registers the callback fired with the response to a custom operation.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
photon_realtime_set_callback_custom_operation_response(callback)
| Argument | Type | Description |
|---|---|---|
| callback | Function | The function to call on a custom operation response. |
Returns:
Whether the callback was set.
Triggers:
The callback is invoked with the following arguments:
| Key | Type | Description |
|---|---|---|
| operation_code | Real | The operation code the response is for. |
| return_code | Real | The server's return code. |
| debug_message | String | A human-readable debug message. |
| parameters | Struct | The response parameters, as a GML struct. |
Removes the debug callback registered with photon_realtime_set_callback_debug.
Syntax:
photon_realtime_remove_callback_debug()
Returns:
Whether the callback was removed.
Removes the connected callback registered with photon_realtime_set_callback_connected.
Syntax:
photon_realtime_remove_callback_connected()
Returns:
Whether the callback was removed.
Removes the disconnected callback registered with photon_realtime_set_callback_disconnected.
Syntax:
photon_realtime_remove_callback_disconnected()
Returns:
Whether the callback was removed.
Removes the connection-error callback registered with photon_realtime_set_callback_connection_error.
Syntax:
photon_realtime_remove_callback_connection_error()
Returns:
Whether the callback was removed.
Removes the client-error callback registered with photon_realtime_set_callback_client_error.
Syntax:
photon_realtime_remove_callback_client_error()
Returns:
Whether the callback was removed.
Removes the server-error callback registered with photon_realtime_set_callback_server_error.
Syntax:
photon_realtime_remove_callback_server_error()
Returns:
Whether the callback was removed.
Removes the warning callback registered with photon_realtime_set_callback_warning.
Syntax:
photon_realtime_remove_callback_warning()
Returns:
Whether the callback was removed.
Removes the join-room callback registered with photon_realtime_set_callback_join_room_event.
Syntax:
photon_realtime_remove_callback_join_room_event()
Returns:
Whether the callback was removed.
Removes the leave-room callback registered with photon_realtime_set_callback_leave_room_event.
Syntax:
photon_realtime_remove_callback_leave_room_event()
Returns:
Whether the callback was removed.
Removes the custom-event callback registered with photon_realtime_set_callback_custom_event.
Syntax:
photon_realtime_remove_callback_custom_event()
Returns:
Whether the callback was removed.
Removes the room-properties-change callback registered with photon_realtime_set_callback_room_properties_change.
Syntax:
photon_realtime_remove_callback_room_properties_change()
Returns:
Whether the callback was removed.
Removes the player-properties-change callback registered with photon_realtime_set_callback_player_properties_change.
Syntax:
photon_realtime_remove_callback_player_properties_change()
Returns:
Whether the callback was removed.
Removes the room-list-update callback registered with photon_realtime_set_callback_room_list_update.
Syntax:
photon_realtime_remove_callback_room_list_update()
Returns:
Whether the callback was removed.
Removes the app-stats-update callback registered with photon_realtime_set_callback_app_stats_update.
Syntax:
photon_realtime_remove_callback_app_stats_update()
Returns:
Whether the callback was removed.
Removes the lobby-stats-update callback registered with photon_realtime_set_callback_lobby_stats_update.
Syntax:
photon_realtime_remove_callback_lobby_stats_update()
Returns:
Whether the callback was removed.
Removes the cache-slice-changed callback registered with photon_realtime_set_callback_cache_slice_changed.
Syntax:
photon_realtime_remove_callback_cache_slice_changed()
Returns:
Whether the callback was removed.
Removes the master-client-changed callback registered with photon_realtime_set_callback_master_client_changed.
Syntax:
photon_realtime_remove_callback_master_client_changed()
Returns:
Whether the callback was removed.
Removes the properties-change-failed callback registered with photon_realtime_set_callback_properties_change_failed.
Syntax:
photon_realtime_remove_callback_properties_change_failed()
Returns:
Whether the callback was removed.
Removes the custom-authentication-step callback registered with photon_realtime_set_callback_custom_authentication_step.
Syntax:
photon_realtime_remove_callback_custom_authentication_step()
Returns:
Whether the callback was removed.
Removes the available-regions callback registered with photon_realtime_set_callback_available_regions.
Syntax:
photon_realtime_remove_callback_available_regions()
Returns:
Whether the callback was removed.
Removes the secret-receival callback registered with photon_realtime_set_callback_secret_receival.
Syntax:
photon_realtime_remove_callback_secret_receival()
Returns:
Whether the callback was removed.
Removes the direct-connection-established callback registered with photon_realtime_set_callback_direct_connection_established.
Syntax:
photon_realtime_remove_callback_direct_connection_established()
Returns:
Whether the callback was removed.
Removes the direct-connection-failed callback registered with photon_realtime_set_callback_direct_connection_failed.
Syntax:
photon_realtime_remove_callback_direct_connection_failed()
Returns:
Whether the callback was removed.
Removes the direct-message callback registered with photon_realtime_set_callback_direct_message.
Syntax:
photon_realtime_remove_callback_direct_message()
Returns:
Whether the callback was removed.
Removes the custom-operation-response callback registered with photon_realtime_set_callback_custom_operation_response.
Syntax:
photon_realtime_remove_callback_custom_operation_response()
Returns:
Whether the callback was removed.
Returns the sender's player number for the next buffered binary event without removing it from the queue.
Syntax:
photon_realtime_peek_next_buffer_event_player_number()
Returns:
The player number of the next event's sender.
The states the Realtime client moves through, returned by photon_realtime_get_state.
These constants are referenced by the following functions:
| Member | Description |
|---|---|
Unknown |
Unknown state. |
Uninitialized |
The client has not been initialised. |
PeerCreated |
The peer has been created but is not connecting. |
ConnectingToNameserver |
Connecting to the name server. |
ConnectedToNameserver |
Connected to the name server. |
DisconnectingFromNameserver |
Disconnecting from the name server. |
Connecting |
Connecting to the master server. |
Connected |
Connected to the master server. |
WaitingForCustomAuthNextStep |
Waiting on the next custom authentication step. |
Authenticated |
Authenticated on the master server. |
JoinedLobby |
Joined a matchmaking lobby. |
DisconnectingFromMasterserver |
Disconnecting from the master server. |
ConnectingToGameserver |
Connecting to a game server. |
ConnectedToGameserver |
Connected to a game server. |
AuthenticatedOnGameServer |
Authenticated on the game server. |
Joining |
Joining a room. |
Joined |
Joined a room. |
Leaving |
Leaving a room. |
Left |
Left a room. |
DisconnectingFromGameserver |
Disconnecting from the game server. |
ConnectingToMasterserver |
Connecting back to the master server. |
ConnectedComingFromGameserver |
Connected to the master server after leaving a game server. |
AuthenticatedComingFromGameserver |
Authenticated on the master server after leaving a game server. |
Disconnecting |
Disconnecting. |
Disconnected |
Fully disconnected. |
The types of matchmaking lobby.
These constants are referenced by the following functions:
These constants are referenced by the following structs:
| Member | Description |
|---|---|
Default |
The default lobby. |
SqlLobby |
An SQL-filterable lobby. |
AsyncRandomLobby |
An asynchronous random-matchmaking lobby. |
How rooms are filled during random matchmaking.
These constants are referenced by the following structs:
| Member | Description |
|---|---|
FillRoom |
Fill rooms to capacity before starting new ones. |
SerialMatching |
Match rooms serially. |
RandomMatching |
Match into a random room. |
The direct (peer-to-peer) connection modes.
| Member | Description |
|---|---|
None |
No direct connections. |
AllToOthers |
Every client connects directly to every other. |
MasterToOthers |
The master client connects directly to the others. |
AllToAll |
All clients connect directly to all clients. |
MasterToAll |
The master client connects directly to all clients. |
The reasons a client can be disconnected, returned by photon_realtime_get_disconnected_cause.
These constants are referenced by the following functions:
| Member | Description |
|---|---|
Unknown |
Unknown cause. |
None |
No disconnect. |
ServerUserLimit |
The server's user limit was reached. |
ExceptionOnConnect |
An exception occurred while connecting. |
DisconnectByServer |
The server closed the connection. |
DisconnectByServerLogic |
Server-side logic closed the connection. |
TimeoutDisconnect |
The connection timed out. |
Exception |
A client-side exception occurred. |
InvalidAuthentication |
Authentication was invalid. |
MaxCcuReached |
The application's maximum concurrent-user limit was reached. |
InvalidRegion |
The requested region was invalid. |
OperationNotAllowed |
An operation was not allowed in the current state. |
CustomAuthenticationFailed |
Custom authentication failed. |
ClientVersionTooOld |
The client version is too old. |
ClientVersionInvalid |
The client version is invalid. |
DashboardVersionInvalid |
The dashboard-configured version is invalid. |
AuthenticationTicketExpired |
The authentication ticket expired. |
OperationLimit |
An operation limit was exceeded. |
How the connection region is selected.
| Member | Description |
|---|---|
Default |
Use the default region behaviour. |
Select |
Use an explicitly selected region. |
Best |
Use the region with the best ping. |
The Photon server types.
| Member | Description |
|---|---|
NameServer |
The name server. |
MasterServer |
The master server. |
The custom authentication providers supported by Photon.
These constants are referenced by the following structs:
| Member | Description |
|---|---|
Custom |
A custom authentication service. |
Steam |
Steam authentication. |
Facebook |
Facebook authentication. |
Oculus |
Oculus authentication. |
PlayStation4 |
PlayStation 4 authentication. |
Xbox |
Xbox authentication. |
Viveport |
Viveport authentication. |
NintendoSwitch |
Nintendo Switch authentication. |
PlayStation5 |
PlayStation 5 authentication. |
Epic |
Epic authentication. |
FacebookGaming |
Facebook Gaming authentication. |
None |
No custom authentication. |
Which players receive a raised event.
These constants are referenced by the following structs:
| Member | Description |
|---|---|
Others |
All players except the sender. |
All |
All players including the sender. |
MasterClient |
Only the room's master client. |
How a raised event is cached on the server.
These constants are referenced by the following structs:
| Member | Description |
|---|---|
DoNotCache |
Do not cache the event. |
MergeCache |
Merge the event into the cache. |
ReplaceCache |
Replace the cached event. |
RemoveCache |
Remove the event from the cache. |
AddToRoomCache |
Add the event to the room cache. |
AddToRoomCacheGlobal |
Add the event to the global room cache. |
RemoveFromRoomCache |
Remove the event from the room cache. |
RemoveFromRoomCacheForActorsLeft |
Remove cached events for actors that have left. |
SliceIncIndex |
Increment the cache slice index. |
SliceSetIndex |
Set the cache slice index. |
SlicePurgeIndex |
Purge a specific cache slice. |
SlicePurgeUpToIndex |
Purge cache slices up to an index. |
The LoadBalancing operation codes. Primarily useful when interpreting custom operation responses.
| Member | Description |
|---|---|
Leave |
Leave a room. |
RaiseEvent |
Raise an event. |
SetProperties |
Set properties. |
GetProperties |
Get properties. |
ChangeGroups |
Change interest groups. |
AuthOnce |
Authenticate once. |
Authenticate |
Authenticate. |
JoinLobby |
Join a lobby. |
LeaveLobby |
Leave a lobby. |
CreateRoom |
Create a room. |
JoinRoom |
Join a room. |
JoinRandomRoom |
Join a random room. |
FindFriends |
Find friends. |
LobbyStats |
Request lobby stats. |
GetRegions |
Get available regions. |
Rpc |
Call a WebRPC. |
GetRoomList |
Get a room list. |
The LoadBalancing event codes. Primarily useful when interpreting incoming events.
| Member | Description |
|---|---|
Join |
A player joined. |
Leave |
A player left. |
PropertiesChanged |
Properties changed. |
ErrorInfo |
Error information from the server. |
CacheSliceChanged |
The cache slice changed. |
RoomList |
A room list was received. |
RoomListUpdate |
A room list update was received. |
AppStats |
Application statistics were received. |
LobbyStats |
Lobby statistics were received. |
Auth |
An authentication event. |
PunchMsg |
A NAT-punchthrough message. |
VoiceFrameData |
Voice frame data. |
VoiceData |
Voice data. |
MaxCustomEvCode |
The highest reserved event code; custom codes must stay below it. |
Application-level result codes reported by operations and the connected callback.
These constants are referenced by the following functions:
- photon_realtime_operation_create_room
- photon_realtime_operation_join_or_create_room
- photon_realtime_operation_join_room
- photon_realtime_operation_join_random_room
- photon_realtime_operation_leave_room
- photon_realtime_operation_join_random_or_create_room
- photon_realtime_set_callback_connected
| Member | Description |
|---|---|
Ok |
The operation succeeded. |
InvalidAuthentication |
Authentication was invalid. |
GameIdAlreadyExists |
A room with that name already exists. |
GameFull |
The room is full. |
GameClosed |
The room is closed. |
AlreadyMatched |
The client is already matched. |
ServerFull |
The server is full. |
UserBlocked |
The user is blocked. |
NoMatchFound |
No matching room was found. |
GameDoesNotExist |
The room does not exist. |
MaxCcuReached |
The maximum concurrent-user limit was reached. |
InvalidRegion |
The region was invalid. |
CustomAuthenticationFailed |
Custom authentication failed. |
AuthTicketExpired |
The authentication ticket expired. |
PluginReportedError |
A server plugin reported an error. |
PluginMismatch |
A server plugin mismatch occurred. |
JoinFailedPeerAlreadyJoined |
Join failed: the peer already joined. |
JoinFailedFoundInactiveJoiner |
Join failed: an inactive joiner was found. |
JoinFailedRejoinNotFound |
Join failed: no actor to rejoin was found. |
JoinFailedFoundExcludedUserId |
Join failed: the user ID is excluded. |
JoinFailedFoundActiveJoiner |
Join failed: an active joiner was found. |
HttpLimitReached |
The HTTP request limit was reached. |
ExternalHttpCallFailed |
An external HTTP call failed. |
OperationLimitReached |
An operation limit was reached. |
SlotError |
A slot-reservation error occurred. |
InvalidEncryptionParameters |
The encryption parameters were invalid. |
ClientVersionTooOld |
The client version is too old. |
ClientVersionInvalid |
The client version is invalid. |
DashboardVersionInvalid |
The dashboard-configured version is invalid. |
Describes a binary event read with photon_realtime_receive_one_event_buffer.
This struct is referenced by the following functions:
- photon_chat_receive_one_broadcast_buffer
- photon_realtime_receive_one_event_buffer
- photon_voice_receive_frame_buffer
| Member | Type | Description |
|---|---|---|
| ok | Boolean | Whether an event was successfully read. |
| player_number | Real | The sender's player number. |
| event_code | Real | The event's custom event code. |
| bytes_written | Real | The number of bytes written into the output buffer. |
Options describing random-room matchmaking.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| max_players | Real | Only match rooms with this maximum player count. |
| matchmaking_mode | PhotonRealtimeMatchmakingMode | How rooms are filled during matchmaking. |
| lobby_name | String | The lobby to match within. |
| lobby_type | PhotonRealtimeLobbyType | The type of lobby to match within. |
| sql_filter | String | An SQL-style filter applied when using an SQL lobby. |
| expected_users | Array of String | User IDs reserved a slot in the matched room. |
Options describing a room to create.
This struct is referenced by the following functions:
- photon_realtime_operation_create_room
- photon_realtime_operation_join_or_create_room
- photon_realtime_operation_join_random_or_create_room
| Member | Type | Description |
|---|---|---|
| max_players | Real | Maximum number of players allowed in the room (0 for unlimited). |
| is_visible | Boolean | Whether the room is listed in the lobby. |
| is_open | Boolean | Whether the room accepts new players. |
| lobby_name | String | The lobby the room belongs to. |
| lobby_type | PhotonRealtimeLobbyType | The type of the room's lobby. |
| player_ttl | Real | How long (ms) an inactive player is kept before being removed. |
| empty_room_ttl | Real | How long (ms) an empty room is kept alive before being removed. |
| suppress_room_events | Boolean | Whether to suppress join/leave events for the room. |
| publish_user_id | Boolean | Whether player user IDs are visible to others in the room. |
| lobby_keys | Array of String | The custom-property keys exposed to the lobby for matchmaking. |
| expected_users | Array of String | User IDs reserved a slot in the room. |
Options passed to photon_realtime_operation_join_room.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| rejoin | Boolean | Whether to rejoin as a previously-inactive actor. |
| cache_slice_index | Real | The event-cache slice index to fetch on join. |
Targeting and caching options for raised events.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| receiver_group | PhotonRealtimeReceiverGroup | Which group of players receives the event. |
| interest_group | Real | The interest group the event belongs to. |
| event_cache | PhotonRealtimeEventCache | How the event is cached on the server. |
| channel_id | Real | The sequencing channel to send on. |
| cache_slice_index | Real | The cache slice index to target. |
| encrypt | Boolean | Whether to encrypt the event payload. |
| target_players | Array of Real | Target specific player numbers. An empty array broadcasts to receiver_group (default: Others). |
Authentication values for a custom authentication provider.
This struct is referenced by the following functions:
This struct is referenced by the following structs:
| Member | Type | Description |
|---|---|---|
| user_id | String | Unique identifier for this player. Used by Photon for matchmaking and friend lookup. |
| auth_type | PhotonRealtimeCustomAuthType | Authentication provider. Defaults to PhotonRealtimeCustomAuthType.None. |
| parameters | String | Token/parameters string passed to the authentication provider. |
A friend-status entry delivered by photon_realtime_operation_find_friends.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| user_id | String | The friend's user ID. |
| is_online | Boolean | Whether the friend is currently online. |
| room | String | The room the friend is in, if any. |
| is_in_room | Boolean | Whether the friend is currently in a room. |
A snapshot of a single room in the lobby room list.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| name | String | The room's name. |
| player_count | Real | The current number of players in the room. |
| max_players | Real | The room's maximum player count. |
| is_open | Boolean | Whether the room is open to new players. |
| custom_properties | Struct | The room's lobby-exposed custom properties, as a GML struct. |
A statistics entry for a single lobby, delivered by photon_realtime_operation_lobby_stats and the lobby-stats-update callback.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| name | String | The lobby's name. |
| type | PhotonRealtimeLobbyType | The lobby's type. |
| peer_count | Real | The number of players in the lobby. |
| room_count | Real | The number of rooms in the lobby. |
Options passed to photon_realtime_connect.
This struct is referenced by the following functions:
| Member | Type | Description |
|---|---|---|
| authentication_values | PhotonRealtimeAuthenticationValues | Authentication values for a custom auth provider. |
| username | String | Display name visible to other players. Separate from the user_id in authentication_values. |
| server_address | String | Override the Photon name server address. Leave unset to use the default cloud. |
| try_use_datagram_encryption | Boolean | Whether to attempt datagram encryption for the connection. |
| use_background_thread | Boolean | Whether to use a background send/receive thread. Honored only on Nintendo Switch; ignored on other platforms. |
GameMaker 2026