Functions and constants for interacting with Photon Realtime
Version: stable
realtime.init(app_id)
Initialize Realtime by creating a load balanced client
PARAMETERS
app_id |
string |
realtime.connect(options,callback)
Connect to the server. - username - use_datagram_encryption - server_type See SERVER_TYPE_* enums - server_address The IP address or domain name and optionally the port number to connect to. IP addresses can be in IPv4 or IPv6 format - auth_data Sets the HTTP POST data, that will be forwarded to the authentication service, to the provided data. - auth_parameters The HTTP GET parameters that will be forwarded to the authentication service to the provided parameters. - auth_type The type of the "Custom Authentication" service that will be used. See AUTH_* enums
PARAMETERS
options |
None |
Table with connection options |
callback |
None |
realtime.update()
Update Realtime. Call this from a script component.
PARAMETERS
None
realtime.disconnect()
Disconnect from server.
PARAMETERS
None
realtime.join_lobby(lobby_name,lobby_type)
Join lobby.
PARAMETERS
lobby_name |
string |
|
lobby_type |
number |
realtime.leave_lobby()
Leave lobby.
PARAMETERS
None
realtime.create_room(game_id,room_options,expected_users)
Create room. Local game_id = "1234" local room_options = { is_visible = false, is_open = false, supress_room_events = false, max_players = 4, player_ttl = 0, empty_room_ttl = 0, lobby_type = realtime.LOBBYTYPE_DEFAULT, lobby_name = "", publish_user_id = "", direct_mode = realtime.DIRECTMODE_NONE, props_listed_in_lobby = {}, custom_room_properties = {}, } local expected_users = {} realtime.create_room(game_id, room_options, expected_users)
PARAMETERS
game_id |
string |
The name to create a room with. Must be unique and not in use or the room can't be created. If this is an empty string, then the server will assign a GUID as name. |
room_options |
table |
|
expected_users |
table |
realtime.join_room(game_id,join_options)
Join room. Local game_id = "1234" local join_options = { rejoin = false, cache_slice_index = 0, expected_users = {}, } realtime.join_room(game_id, join_options)
PARAMETERS
game_id |
string |
The name to create a room with. Must be unique and not in use or the room can't be created. If this is an empty string, then the server will assign a GUID as name. |
join_options |
table |
realtime.join_or_create_room(game_id,room_options,join_options)
Join or create room. Local game_id = "1234" local room_options = { is_visible = false, is_open = false, supress_room_events = false, max_players = 4, player_ttl = 0, empty_room_ttl = 0, lobby_type = realtime.LOBBYTYPE_DEFAULT, lobby_name = "", publish_user_id = "", direct_mode = realtime.DIRECTMODE_NONE, props_listed_in_lobby = {}, custom_room_properties = {}, } local join_options = { custom_room_properties = {}, max_players = 0, matchmaking_mode = realtime.MATCHMAKINGMODE_FILL_ROOM, lobby_name = "", lobby_type = realtime.LOBBYTYPE_DEFAULT, sql_lobby_filter = "", expected_users = {}, }
PARAMETERS
game_id |
string |
The name to create a room with. Must be unique and not in use or the room can't be created. If this is an empty string, then the server will assign a GUID as name. |
room_options |
table |
|
join_options |
table |
realtime.join_or_create_random_room(game_id,room_options,join_options)
Join or create random room. Local game_id = "1234" local room_options = { is_visible = false, is_open = false, supress_room_events = false, max_players = 4, player_ttl = 0, empty_room_ttl = 0, lobby_type = realtime.LOBBYTYPE_DEFAULT, lobby_name = "", publish_user_id = "", direct_mode = realtime.DIRECTMODE_NONE, props_listed_in_lobby = {}, custom_room_properties = {}, } local join_options = { custom_room_properties = {}, max_players = 0, matchmaking_mode = realtime.MATCHMAKINGMODE_FILL_ROOM, lobby_name = "", lobby_type = realtime.LOBBYTYPE_DEFAULT, sql_lobby_filter = "", expected_users = {}, } realtime.join_or_create_random_room(game_id, room_options, join_options)
PARAMETERS
game_id |
string |
The name to create a room with. Must be unique and not in use or the room can't be created. If this is an empty string, then the server will assign a GUID as name. |
room_options |
table |
|
join_options |
table |
realtime.int JoinRandomRoom(join_options)
Join random room. Local join_options = { custom_room_properties = {}, max_players = 0, matchmaking_mode = realtime.MATCHMAKINGMODE_FILL_ROOM, lobby_name = "", lobby_type = realtime.LOBBYTYPE_DEFAULT, sql_lobby_filter = "", expected_users = {}, } realtime.join_random_room(join_options)
PARAMETERS
join_options |
table |
realtime.leave_room(will_come_back,send_auth_cookie)
Leave room.
PARAMETERS
will_come_back |
boolean |
|
send_auth_cookie |
boolean |
realtime.get_room_list()
Get room list.
PARAMETERS
None
realtime.raise_event(reliable,parameter,event_code,options)
Sends in-game data to other players in the game.
PARAMETERS
reliable |
boolean |
|
parameter |
number |
|
event_code |
number |
|
options |
table |
(channel_id, event_caching, receiver_group, interest_group, cache_slice_index, target_players, web_flags, encrypt) |
RETURNS
boolea |
realtime.set_auto_join_lobby(auto_join)
Set the auto join lobby flag. The value of the autoJoinLobby flag determines if the client will automatically join the default lobby whenever it has successfully connected and whenever it leaves a game room.
PARAMETERS
auto_join |
boolean |
EVENT_CONNECTIONERRORRETURN
EVENT_CLIENTERRORRETURN
EVENT_WARNINGRETURN
EVENT_SERVERERRORRETURN
EVENT_JOINROOMEVENTACTION
EVENT_LEAVEROOMEVENTACTION
EVENT_CUSTOMEVENTACTION
EVENT_CONNECTRETURN
EVENT_DISCONNECTRETURN
EVENT_CREATEROOMRETURN
EVENT_JOINORCREATEROOMRETURN
EVENT_JOINRANDOMORCREATEROOMRETURN
EVENT_JOINROOMRETURN
EVENT_JOINRANDOMROOMRETURN
EVENT_LEAVEROOMRETURN
EVENT_JOINLOBBYRETURN
EVENT_LEAVELOBBYRETURN
EVENT_ONFINDFRIENDSRESPONSE
EVENT_ONLOBBYSTATSRESPONSE
EVENT_WEBRPCRETURN
EVENT_ONROOMLISTUPDATE
EVENT_ONROOMPROPERTIESCHANGE
EVENT_ONPLAYERPROPERTIESCHANGE
EVENT_ONAPPSTATSUPDATE
EVENT_ONLOBBYSTATSUPDATE
EVENT_ONCACHESLICECHANGED
EVENT_ONMASTERCLIENTCHANGED
EVENT_ONCUSTOMAUTHENTICATIONINTERMEDIATESTEP
EVENT_ONAVAILABLEREGIONS
EVENT_ONSECRETRECEIVAL
EVENT_ONDIRECTCONNECTIONESTABLISHED
EVENT_ONDIRECTCONNECTIONFAILEDTOESTABLISH
EVENT_ONDIRECTMESSAGE
EVENT_ONCUSTOMOPERATIONRESPONSE
EVENT_ONGETROOMLISTRESPONSE
Use a custom authentication service.
Authenticates users by their Steam Account. Pass L"ticket=[ticket]" to setParameters().
Authenticates users by their Facebook Account. Pass L"token=[token]" to setParameters().
Authenticates users by their Oculus Account. Pass L"userid=[userid]&nonce=[nonce]" to setParameters().
Authenticates users by their PSN Account. Pass L"token=[token]&env=[env]&userName=[userName]" to setParameters().
Authenticates users by their XBox Network Account. Pass the XSTS token to setData().
Authenticates users by their HTC Viveport Account and user token. Pass L"userToken=[userToken]" to setParameters().
Authenticates users by their Nintendo Account. Pass L"token=[token]&appversion=[appversion]" to setParameters(). The appversion is optional.
Authenticates users by their PSN Account. Pass L"token=[token]&env=[env]&userName=[userName]" to setParameters().
Authenticates users by their Epic Online Services (EOS) Account. Pass L"token=[token]&ownershipToken=[ownershipToken]" to setParameters(). The ownershipToken is optional.
Authenticates users by their Facebook Account. Pass L"token=[token]" to setParameters().
Disables custom authentication.
Photon Cloud and for self-hosted Photon 5 or higher Server instances
Self-hosted Photon 4 Server instances
Fills up rooms (oldest first) to get players together as fast as possible. Default. Makes most sense with MaxPlayers > 0 and games that can only start with more players.
Distributes players across available rooms sequentially but takes filters into account. Without filters, rooms get players evenly distributed.
Joins a (fully) random room. Expected properties must match, but aside from this, any available room might be selected.
This lobby type is used unless another lobby type is specified. Room lists will be sent and Client::opJoinRandomRoom() can filter by matching properties.
This lobby type lists rooms like type DEFAULT but SQL-like "where" clauses for filtering can be used with Client::opJoinRandomRoom(). This allows 'bigger', 'less', 'or' and 'and' combinations.
This lobby does not send room lists. It is only used for Client::opJoinRandomRoom(). It keeps rooms available for matchmaking for a while even when there are only inactive users left.
Do not create any 2p2 connections between the clients. This is the default.
Each client establishes a direct connection with every other client inside the room.
The master client establishes a direct connection with every other client inside the room. All other clients only establish a direct connection with the master client but not with each other.
Each client establishes a direct connection with every client inside the room, including itself.
The master client establishes a direct connection with every client inside the room, including itself. All other clients only establish a direct connection with the master client but not with each other.