realtime
Version: stable
Functions
realtime.init()
realtime.init(app_id,app_version,listener)
Initialize Realtime by creating a load balanced client
PARAMETERS
app_id |
string
|
|
app_version |
string
|
|
listener |
function
|
|
realtime.connect()
realtime.connect(options)
Connect to the server.
PARAMETERS
options |
table
|
Table with connection options
username |
string
|
|
use_datagram_encryption |
boolean
|
|
server_type |
number
|
See SERVER_TYPE_* enums |
server_address |
string
|
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 |
string
|
Sets the HTTP POST data, that will be forwarded to the authentication service, to the provided data. |
auth_parameters |
string
|
The HTTP GET parameters that will be forwarded to the authentication service to the provided parameters. |
auth_type |
number
|
The type of the "Custom Authentication" service that will be used. See AUTH_* enums |
|
realtime.update()
realtime.update()
Update Realtime. Call this from a script component.
PARAMETERS
None
realtime.disconnect()
realtime.disconnect()
Disconnect from server.
PARAMETERS
None
realtime.join_lobby()
realtime.join_lobby(lobby_name,lobby_type)
Join lobby.
PARAMETERS
lobby_name |
string
|
|
lobby_type |
number
|
|
realtime.leave_lobby()
realtime.leave_lobby()
Leave lobby.
PARAMETERS
None
realtime.create_room()
realtime.create_room(game_id,room_options,expected_users)
Create room.
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
|
is_visible |
boolean
|
|
is_open |
boolean
|
|
supress_room_events |
boolean
|
|
max_players |
number
|
|
player_ttl |
number
|
|
empty_room_ttl |
number
|
|
lobby_type |
number
|
Realtime.LOBBYTYPE_* enum |
lobby_name |
string
|
|
publish_user_id |
string
|
|
direct_mode |
numbmer
|
Realtime.DIRECTMODE_* enum |
props_listed_in_lobby |
table
|
|
custom_room_properties |
table
|
|
|
expected_users |
table
|
|
realtime.join_room()
realtime.join_room(game_id,join_options)
Join room.
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
|
rejoin |
boolean
|
|
cache_slice_index |
number
|
|
expected_users |
table
|
|
|
realtime.join_or_create_room()
realtime.join_or_create_room(game_id,room_options,join_options)
Join or create room.
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
|
is_visible |
boolean
|
|
is_open |
boolean
|
|
supress_room_events |
boolean
|
|
max_players |
number
|
|
player_ttl |
number
|
|
empty_room_ttl |
number
|
|
lobby_type |
number
|
Realtime.LOBBYTYPE_* enum |
lobby_name |
string
|
|
publish_user_id |
string
|
|
direct_mode |
numbmer
|
Realtime.DIRECTMODE_* enum |
props_listed_in_lobby |
table
|
|
custom_room_properties |
table
|
|
|
join_options |
table
|
custom_room_properties |
table
|
|
max_players |
number
|
|
matchmaking_mode |
number
|
Realtime.MATCHMAKINGMODE_* enum |
lobby_name |
string
|
|
lobby_type |
number
|
Realtime.LOBBYTYPE_* enum |
sql_lobby_filter |
string
|
|
expected_users |
table
|
|
|
realtime.join_or_create_random_room()
realtime.join_or_create_random_room(game_id,room_options,join_options)
Join or create random room.
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
|
is_visible |
boolean
|
|
is_open |
boolean
|
|
supress_room_events |
boolean
|
|
max_players |
number
|
|
player_ttl |
number
|
|
empty_room_ttl |
number
|
|
lobby_type |
number
|
Realtime.LOBBYTYPE_* enum |
lobby_name |
string
|
|
publish_user_id |
string
|
|
direct_mode |
numbmer
|
Realtime.DIRECTMODE_* enum |
props_listed_in_lobby |
table
|
|
custom_room_properties |
table
|
|
|
join_options |
table
|
custom_room_properties |
table
|
|
max_players |
number
|
|
matchmaking_mode |
number
|
Realtime.MATCHMAKINGMODE_* enum |
lobby_name |
string
|
|
lobby_type |
number
|
Realtime.LOBBYTYPE_* enum |
sql_lobby_filter |
string
|
|
expected_users |
table
|
|
|
realtime.join_random_room()
realtime.join_random_room(join_options)
Join random room.
PARAMETERS
join_options |
table
|
custom_room_properties |
table
|
|
max_players |
number
|
|
matchmaking_mode |
number
|
Realtime.MATCHMAKINGMODE_* enum |
lobby_name |
string
|
|
lobby_type |
number
|
Realtime.LOBBYTYPE_* enum |
sql_lobby_filter |
string
|
|
expected_users |
table
|
|
|
realtime.leave_room()
realtime.leave_room(will_come_back,send_auth_cookie)
Leave room.
PARAMETERS
will_come_back |
boolean
|
|
send_auth_cookie |
boolean
|
|
realtime.get_room_list()
realtime.get_room_list()
Get room list.
PARAMETERS
None
realtime.raise_event()
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)
channel_id |
number
|
|
event_caching |
number
|
|
receiver_group |
number
|
|
interest_group |
number
|
|
cache_slice_index |
number
|
|
target_players |
number
|
|
web_flags |
number
|
|
encrypt |
boolean
|
|
|
RETURNS
realtime.set_auto_join_lobby()
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
Constants
EVENT_CONNECTIONERRORRETURN
EVENT_CONNECTIONERRORRETURN
EVENT_CLIENTERRORRETURN
EVENT_CLIENTERRORRETURN
EVENT_WARNINGRETURN
EVENT_WARNINGRETURN
EVENT_SERVERERRORRETURN
EVENT_SERVERERRORRETURN
EVENT_JOINROOMEVENTACTION
EVENT_JOINROOMEVENTACTION
EVENT_LEAVEROOMEVENTACTION
EVENT_LEAVEROOMEVENTACTION
EVENT_CUSTOMEVENTACTION
EVENT_CUSTOMEVENTACTION
EVENT_CONNECTRETURN
EVENT_CONNECTRETURN
EVENT_DISCONNECTRETURN
EVENT_DISCONNECTRETURN
EVENT_CREATEROOMRETURN
EVENT_CREATEROOMRETURN
EVENT_JOINORCREATEROOMRETURN
EVENT_JOINORCREATEROOMRETURN
EVENT_JOINRANDOMORCREATEROOMRETURN
EVENT_JOINRANDOMORCREATEROOMRETURN
EVENT_JOINROOMRETURN
EVENT_JOINROOMRETURN
EVENT_JOINRANDOMROOMRETURN
EVENT_JOINRANDOMROOMRETURN
EVENT_LEAVEROOMRETURN
EVENT_LEAVEROOMRETURN
EVENT_JOINLOBBYRETURN
EVENT_JOINLOBBYRETURN
EVENT_LEAVELOBBYRETURN
EVENT_LEAVELOBBYRETURN
EVENT_ONFINDFRIENDSRESPONSE
EVENT_ONFINDFRIENDSRESPONSE
EVENT_ONLOBBYSTATSRESPONSE
EVENT_ONLOBBYSTATSRESPONSE
EVENT_WEBRPCRETURN
EVENT_WEBRPCRETURN
EVENT_ONROOMLISTUPDATE
EVENT_ONROOMLISTUPDATE
EVENT_ONROOMPROPERTIESCHANGE
EVENT_ONROOMPROPERTIESCHANGE
EVENT_ONPLAYERPROPERTIESCHANGE
EVENT_ONPLAYERPROPERTIESCHANGE
EVENT_ONAPPSTATSUPDATE
EVENT_ONAPPSTATSUPDATE
EVENT_ONLOBBYSTATSUPDATE
EVENT_ONLOBBYSTATSUPDATE
EVENT_ONCACHESLICECHANGED
EVENT_ONCACHESLICECHANGED
EVENT_ONMASTERCLIENTCHANGED
EVENT_ONMASTERCLIENTCHANGED
EVENT_ONCUSTOMAUTHENTICATIONINTERMEDIATESTEP
EVENT_ONAVAILABLEREGIONS
EVENT_ONAVAILABLEREGIONS
EVENT_ONSECRETRECEIVAL
EVENT_ONSECRETRECEIVAL
EVENT_ONDIRECTCONNECTIONESTABLISHED
EVENT_ONDIRECTCONNECTIONESTABLISHED
EVENT_ONDIRECTCONNECTIONFAILEDTOESTABLISH
EVENT_ONDIRECTCONNECTIONFAILEDTOESTABLISH
EVENT_ONDIRECTMESSAGE
EVENT_ONDIRECTMESSAGE
EVENT_ONCUSTOMOPERATIONRESPONSE
EVENT_ONCUSTOMOPERATIONRESPONSE
EVENT_ONGETROOMLISTRESPONSE
EVENT_ONGETROOMLISTRESPONSE
AUTH_CUSTOM
Use a custom authentication service.
AUTH_STEAM
Authenticates users by their Steam Account. Pass L"ticket=[ticket]" to setParameters().
AUTH_FACEBOOK
Authenticates users by their Facebook Account. Pass L"token=[token]" to setParameters().
AUTH_OCULUS
Authenticates users by their Oculus Account. Pass L"userid=[userid]&nonce=[nonce]" to setParameters().
AUTH_PLAYSTATION_4
Authenticates users by their PSN Account. Pass L"token=[token]&env=[env]&userName=[userName]" to setParameters().
AUTH_XBOX
Authenticates users by their XBox Network Account. Pass the XSTS token to setData().
AUTH_VIVEPORT
Authenticates users by their HTC Viveport Account and user token. Pass L"userToken=[userToken]" to setParameters().
AUTH_NINTENDO_SWITCH
Authenticates users by their Nintendo Account. Pass L"token=[token]&appversion=[appversion]" to setParameters(). The appversion is optional.
AUTH_PLAYSTATION_5
Authenticates users by their PSN Account. Pass L"token=[token]&env=[env]&userName=[userName]" to setParameters().
AUTH_EPIC
Authenticates users by their Epic Online Services (EOS) Account. Pass L"token=[token]&ownershipToken=[ownershipToken]" to setParameters(). The ownershipToken is optional.
AUTH_FACEBOOK_GAMING
Authenticates users by their Facebook Account. Pass L"token=[token]" to setParameters().
AUTH_NONE
Disables custom authentication.
SERVER_TYPE_NAME_SERVER
Photon Cloud and for self-hosted Photon 5 or higher Server instances
SERVER_TYPE_MASTER_SERVER
Self-hosted Photon 4 Server instances
MATCHMAKINGMODE_FILL_ROOM
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.
MATCHMAKINGMODE_SERIAL_MATCHING
Distributes players across available rooms sequentially but takes filters into account. Without filters, rooms get players evenly distributed.
MATCHMAKINGMODE_RANDOM_MATCHING
Joins a (fully) random room. Expected properties must match, but aside from this, any available room might be selected.
LOBBYTYPE_DEFAULT
This lobby type is used unless another lobby type is specified. Room lists will be sent and Client::opJoinRandomRoom() can filter by matching properties.
LOBBYTYPE_SQL_LOBBY
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.
LOBBYTYPE_ASYNC_RANDOM_LOBBY
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.
DIRECTMODE_NONE
Do not create any 2p2 connections between the clients. This is the default.
DIRECTMODE_ALL_TO_OTHERS
Each client establishes a direct connection with every other client inside the room.
DIRECTMODE_MASTER_TO_OTHERS
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.
DIRECTMODE_ALL_TO_ALL
Each client establishes a direct connection with every client inside the room, including itself.
DIRECTMODE_MASTER_TO_ALL
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.