API Index
Overview
Setup
Initialize
Achievements
Challenges
Leaderboards
Scores
Players
Real-Time Game
Turn-Based Game
Before you can use Real-Time Game Commands in your game, the GameKit Plugin must be setup as well as initialized.
Real-Time Game Commands
Request Register Real-Time Matchmaker Listener
Request Unregister Real-Time Matchmaker Listener
GameKit Real-Time Matchmaker Events
Show Real-Time Match UI
Show Add Players To Existing Real-Time Match UI
Request Real-Time Auto-Matchmaker
Request Cancel Real-Time Auto-Matchmaker
Request Invite Friends Real-Time Matchmaker
Request Add Players To Existing Real-Time Match
Request Finish Adding Players To Existing Real-Time Match
Request Start Browsing For Nearby Players
Request Stop Browsing For Nearby Players
Get The Number Of Real-Time Match Requests
Request Register Real-Time Listener
GameKit Real-Time Game Events
Request Disconnect Real-Time Match
Send Real-Time Data To All Players
Send Real-Time Data To Players
Request Register Real-Time Matchmaker Listener
Comments: Register Game Center Real-Time matchmaker listener for local player only once for all Real-Time matchmaking events. Note you need to register the Real-Time matchmaker listener before you can call any other Real-Time functions.
Function: request( (string) “registerRealTimeMatchmakerListener”, (table) { listener= (function) onRealTimeMatchmakerCallback } )
Param Table Keys: (function) listener – A function to receive callback events.
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “success” – GameKit success event.
Event Properties:
(string) successDescription – GameKit success description string.
1 2 3 4 |
-- see gameKit real-time matchmaker events gameKit.request( "registerRealTimeMatchmakerListener", { listener=onRealTimeMatchmakerCallback } ) |
Request Unregister Real-Time Matchmaker Listener
Comments: Unregister Game Center Real-Time matchmaker listener for local player. Note after you unregister the Real-Time matchmaker listener your game will not receive
anymore Real-Time matchmaker events and you cannot call any other Real-Time functions.
Function: request( (string) “unregisterRealTimeMatchmakerListener” )
Param Table Keys: none
1 2 3 |
gameKit.request( "unregisterRealTimeMatchmakerListener" ) |
GameKit Real-Time Matchmaker Events
Comments: GameKit Real-Time Matchmaker Events called on local player’s device. Note the Real-Time matchmaker listener needs to be registered before the local player’s device can receive these events.
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “error” – GameKit error event.
(string) “success” – GameKit success event.
(string) “playerAddedToMatch” – Player added to match event.
(string) “nearbyPlayerFound” – Nearby player found event.
(string) “inviteeResponse” – Invitee response event.
(string) “acceptedInvite” – Accepted invite event.
(string) “matchmakingActivity” – Matchmaking activity within the last 60 seconds event.
(string) “matchStarted” – Match started event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(string) successDescription – GameKit success description string.
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(number) remotePlayerCount – Number of current remote players connected to the match not including the local player.
(number) response – GameKit GKInviteeResponse number.
(number) numberOfPlayers – Number of players that have searched for a match within the last 60 seconds.
(number) playersCount – Number of player tables in the players array.
(array) players – Array of player tables.
Player Table Keys:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(string) displayName – A string to display the name for the player. If the player is a friend of the local player, then the display name is the actual name of the player. If the player is not a friend, then the display name is the player’s alias.
(boolean) isFriend – A Boolean that indicates whether the player is a friend of the local player or not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
local function onRealTimeMatchmakerCallback(event) print( 'onRealTimeMatchmakerCallback event.name = ' .. event.name ) print( 'onRealTimeMatchmakerCallback event.type = ' .. event.type ) if( event.type == "error" ) then print( 'onRealTimeMatchmakerCallback event.errorCode = ' .. event.errorCode ) print( 'onRealTimeMatchmakerCallback event.errorDescription = ' .. event.errorDescription ) elseif( event.type == "success" ) then print( 'onRealTimeMatchmakerCallback event.successDescription = ' .. event.successDescription ) elseif( event.type == "playerAddedToMatch" ) then print( 'onRealTimeMatchmakerCallback added to match event.playerID = ' .. event.playerID ) print( 'onRealTimeMatchmakerCallback match event.playersCount = ' .. tostring(event.playersCount) ) elseif( event.type == "nearbyPlayerFound" ) then print( 'onRealTimeMatchmakerCallback event.playerID = ' .. event.playerID ) elseif( event.type == "inviteeResponse" ) then print( 'onRealTimeMatchmakerCallback event.playerID = ' .. event.playerID ) print( 'onRealTimeMatchmakerCallback event.response = ' .. tostring(event.response) ) elseif( event.type == "acceptedInvite" ) then print( 'onRealTimeMatchmakerCallback - local player accepted invite' ) -- use one of the below methods to match for invite -- gameKit.show( "gameCenterRealTimeMatchWithInviteUI" ) -- gameKit.request( "realTimeMatchForInvite" ) elseif( event.type == "matchmakingActivity" ) then print( 'onRealTimeMatchmakerCallback event.numberOfPlayers = ' .. tostring(event.numberOfPlayers) ) elseif( event.type == "matchStarted" ) then for i = 1, event.playersCount do print( 'onRealTimeMatchmakerCallback player ' .. tostring(i) .. ' playerID = ' .. event.players[i].playerID ) print( 'onRealTimeMatchmakerCallback player ' .. tostring(i) .. ' displayName = ' .. event.players[i].displayName ) print( 'onRealTimeMatchmakerCallback player ' .. tostring(i) .. ' isFriend = ' .. tostring(event.players[i].isFriend) ) end -- start your real-time game here end end gameKit.request( "registerRealTimeMatchmakerListener", { listener=onRealTimeMatchmakerCallback } ) |
Show Real-Time Match UI
Comments: Show Game Center Real-Time Match UI. Note the optional param keys, playerGroup and playerAttributes, are not required.
Function: (function) show( (string) “gameCenterRealTimeMatchUI”, (table) { minPlayers= (number) 2, maxPlayers= (number) 3, defaultNumPlayers= (number) 3, (optional key) playerGroup= (number) 3, (optional key) playerAttributes= (number) 0xFFFF0000 } )
Param Table Keys:
(number) minPlayers – A minimum number of players that may join the match. The minPlayers number must be at least 2.
(number) maxPlayers – A maximum number of players that may join the match. The maxPlayers number is 4 and must be equal or greater than the minPlayers number.
(number) defaultNumPlayers – A default number of players for the match shown in the Game Center Match UI. The local player can choose to override this by adding or removing players in the Match UI.
(number) playerGroup (optional key) – A number identifying a subset of players allowed to join the match. Only players whose requests share the same playerGroup value are auto-matched by Game Center. For more information, see playerGroup in the Matchmaking Overview Guide.
(number) playerAttributes (optional key) – A hexadecimal number mask that specifies the role that the local player would like to play in the game. For more information, see playerAttributes in the Matchmaking Overview Guide.
Callback Events:
(string) “error” – GameKit error event.
(string) “matchStarted” – Match started event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(number) playersCount – Number of player tables in the players array.
(array) players – Array of player tables.
Player Table Keys:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(string) displayName – A string to display the name for the player. If the player is a friend of the local player, then the display name is the actual name of the player. If the player is not a friend, then the display name is the player’s alias.
(boolean) isFriend – A Boolean that indicates whether the player is a friend of the local player or not.
1 2 3 4 |
-- see gameKit real-time matchmaker events gameKit.show( "gameCenterRealTimeMatchUI", { minPlayers=2, maxPlayers=3, defaultNumPlayers=3, playerGroup=3, playerAttributes=0xFFFF0000 } ) |
Show Add Players To Existing Real-Time Match UI
Comments: Show Game Center add players to existing Real-Time Match UI. This Game Center UI allows the local player to add new players to an existing match rather than creating a new match. Note the optional param keys, playerGroup and playerAttributes, are not required.
Function: (function) show( (string) “gameCenterAddPlayersRealTimeMatchUI”, (table) { minPlayers= (number) 2, maxPlayers= (number) 3, defaultNumPlayers= (number) 3, (optional key) playerGroup= (number) 3, (optional key) playerAttributes= (number) 0xFFFF0000 } )
Param Table Keys:
(number) minPlayers – A minimum number of players that may join the match. The minPlayers number must be at least 2.
(number) maxPlayers – A maximum number of players that may join the match. The maxPlayers number is 4 and must be equal or greater than the minPlayers number.
(number) defaultNumPlayers – A default number of players for the match shown in the Game Center Match UI. The local player can choose to override this by adding or removing players in the Match UI.
(number) playerGroup (optional key) – A number identifying a subset of players allowed to join the match. Only players whose requests share the same playerGroup value are auto-matched by Game Center. For more information, see playerGroup in the Matchmaking Overview Guide.
(number) playerAttributes (optional key) – A hexadecimal number mask that specifies the role that the local player would like to play in the game. For more information, see playerAttributes in the Matchmaking Overview Guide.
Callback Events:
(string) “error” – GameKit error event.
(string) “matchStarted” – Match started event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(number) playersCount – Number of player tables in the players array.
(array) players – Array of player tables.
Player Table Keys:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(string) displayName – A string to display the name for the player. If the player is a friend of the local player, then the display name is the actual name of the player. If the player is not a friend, then the display name is the player’s alias.
(boolean) isFriend – A Boolean that indicates whether the player is a friend of the local player or not.
1 2 3 4 |
-- see gameKit real-time matchmaker events gameKit.show( "gameCenterAddPlayersRealTimeMatchUI", { minPlayers=2, maxPlayers=3, defaultNumPlayers=3, playerGroup=3, playerAttributes=0xFFFF0000 } ) |
Request Real-Time Auto-Matchmaker
Comments: Programmatically Real-Time Auto-Matchmaker for your own custom game auto-match UI. Note the optional param keys, playerGroup and playerAttributes, are not required.
Function: (function) request( (string) “realTimeAutoMatchmaker”, (table) { minPlayers= (number) 2, maxPlayers= (number) 3, (optional key) playerGroup= (number) 3, (optional key) playerAttributes= (number) 0xFFFF0000 } )
Param Table Keys:
(number) minPlayers – A minimum number of players that may join the match. The minPlayers number must be at least 2.
(number) maxPlayers – A maximum number of players that may join the match. The maxPlayers number is 4 and must be equal or greater than the minPlayers number.
(number) playerGroup (optional key) – A number identifying a subset of players allowed to join the match. Only players whose requests share the same playerGroup value are auto-matched by Game Center. For more information, see playerGroup in the Matchmaking Overview Guide.
(number) playerAttributes (optional key) – A hexadecimal number mask that specifies the role that the local player would like to play in the game. For more information, see playerAttributes in the Matchmaking Overview Guide.
Callback Events:
(string) “error” – GameKit error event.
(string) “matchStarted” – Match started event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(number) playersCount – Number of player tables in the players array.
(array) players – Array of player tables.
Player Table Keys:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(string) displayName – A string to display the name for the player. If the player is a friend of the local player, then the display name is the actual name of the player. If the player is not a friend, then the display name is the player’s alias.
(boolean) isFriend – A Boolean that indicates whether the player is a friend of the local player or not.
1 2 3 4 |
-- see gameKit real-time matchmaker events gameKit.request( "realTimeAutoMatchmaker", { minPlayers=2, maxPlayers=3, playerGroup=3, playerAttributes=0xFFFF0000 } ) |
Request Cancel Real-Time Auto-Matchmaker
Comments: Programmatically Cancel Real-Time Auto-Matchmaker for your own custom game auto-match UI.
Function: (function) request( (string) “cancelRealTimeMatchmaker” )
Param Table Keys: none
Callback Events: none
1 2 3 |
gameKit.request( "cancelRealTimeMatchmaker" ) |
Request Invite Friends Real-Time Matchmaker
Comments: Programmatically Invite Friends Real-Time Matchmaker for your own custom game invite friends UI.
Function: request( (string) “inviteFriendsRealTimeMatchmaker”, (table) { minPlayers= (number) 2, maxPlayers= (number) 3, playerIDs= (table) { (string) “G:2073637149” }, inviteMessage= (string) “Let’s play,friend” } )
Param Table Keys:
(number) minPlayers – A minimum number of players that may join the match. The minPlayers number must be at least 2.
(number) maxPlayers – A maximum number of players that may join the match. The maxPlayers number is 4 and must be equal or greater than the minPlayers number.
(table) playerIDs – An array of 1 or more playerID strings that the invite is to be sent to.
(string) inviteMessage – A string displayed on friend’s device when invited to join a match.
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “error” – GameKit error event.
(string) “inviteeResponse” – Invitee response event.
(string) “matchStarted” – Match started event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(number) response – GameKit GKInviteeResponse number.
number) playersCount – Number of player tables in the players array.
(array) players – Array of player tables.
Player Table Keys:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(string) displayName – A string to display the name for the player. If the player is a friend of the local player, then the display name is the actual name of the player. If the player is not a friend, then the display name is the player’s alias.
(boolean) isFriend – A Boolean that indicates whether the player is a friend of the local player or not.
1 2 3 4 5 6 7 8 |
-- mock data, get real playerIDs from Game Center mockFriendOneID = "G:2073637149" mockFriendTwoID = "G:9125286970" -- see gameKit real-time matchmaker events gameKit.request( "inviteFriendsRealTimeMatchmaker", { minPlayers=2, maxPlayers=3, playerIDs={ mockFriendOneID, mockFriendTwoID }, inviteMessage="Let's play a real-time match, friend." } ) |
Request Add Players To Existing Real-Time Match
Comments: Programmatically Add Players To Existing Real-Time Match for your own custom game add friends or auto-match players UI. Note the optional param keys, playerIDs, playerGroup and playerAttributes, are not required. You can use either playerIDs or playerGroup and playerAttributes or neither for your add players request but not both in the same request.
Function: request( (string) “addPlayersToRealTimeMatch”, (table) { minPlayers= (number) 2, maxPlayers= (number) 3, (optional key) playerIDs= (table) { (string) “G:2073637149” }, (optional key) playerGroup= (number) 3, (optional key) playerAttributes= (number) 0xFFFF0000, inviteMessage= (string) “Join our real-time match?” } )
Param Table Keys:
(number) minPlayers – A minimum number of players that may join the match. The minPlayers number must be at least 2.
(number) maxPlayers – A maximum number of players that may join the match. The maxPlayers number is 4 and must be equal or greater than the minPlayers number.
(table) playerIDs (optional key) – An array of 1 or more playerID strings that the player invite is to be sent to.
(number) playerGroup (optional key) – A number identifying a subset of players allowed to join the match. Only players whose requests share the same playerGroup value are auto-matched by Game Center. For more information, see playerGroup in the Matchmaking Overview Guide.
(number) playerAttributes (optional key) – A hexadecimal number mask that specifies the role that the local player would like to play in the game. For more information, see playerAttributes in the Matchmaking Overview Guide.
(string) inviteMessage – A string displayed on player’s device when invited to join a match.
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “error” – GameKit error event.
(string) “inviteeResponse” – Invitee response event.
(string) “matchStarted” – Match started event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(number) response – GameKit GKInviteeResponse number.
number) playersCount – Number of player tables in the players array.
(array) players – Array of player tables.
Player Table Keys:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(string) displayName – A string to display the name for the player. If the player is a friend of the local player, then the display name is the actual name of the player. If the player is not a friend, then the display name is the player’s alias.
(boolean) isFriend – A Boolean that indicates whether the player is a friend of the local player or not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
-- mock data, get real playerIDs from Game Center mockFriendID = "G:2073637149" See GameKit Real-Time Matchmaker Events. -- add friends gameKit.request( "addPlayersToRealTimeMatch", { minPlayers=2, maxPlayers=3, playerIDs={ mockFriendID }, inviteMessage="Join our real-time match?" } ) -- or auto-match add players gameKit.request( "addPlayersToRealTimeMatch", { minPlayers=2, maxPlayers=3, inviteMessage="Join our real-time match?" } ) -- or gameKit.request( "addPlayersToRealTimeMatch", { minPlayers=2, maxPlayers=3, playerGroup=3, inviteMessage="Join our real-time match?" } ) -- or gameKit.request( "addPlayersToRealTimeMatch", { minPlayers=2, maxPlayers=3, playerAttributes=0xFFFF0000, inviteMessage="Join our real-time match?" } ) -- or gameKit.request( "addPlayersToRealTimeMatch", { minPlayers=2, maxPlayers=3, playerGroup=3, playerAttributes=0xFFFF0000, inviteMessage="Join our real-time match?" } ) |
Request Finish Adding Players To Existing Real-Time Match
Comments: Programmatically Finish Adding Players To Existing Real-Time Match for your own custom game add friends or auto-match players UI. When finished adding players to existing match call finishAddingPlayersToRealTimeMatch to match start the newly added players.
Function: (function) request( (string) “finishAddingPlayersToRealTimeMatch” )
Param Table Keys: none
Callback Events: none
1 2 3 |
gameKit.request( "finishAddingPlayersToRealTimeMatch" ) |
Request Start Browsing For Nearby Players
Comments: Programmatically Start Browsing For Nearby Players through Bluetooth or WiFi on the same subnet. After enabling browsing for nearby players, use the responses to populate your own custom game UI with information about nearby players. If a player wants to invite a player to a game, add that player’s player identifier to a real-time match request by calling either the inviteFriendsRealTimeMatchmaker to create a match or addPlayersToRealTimeMatch to update an existing match with the new player. Note that you can only use this method when you are implementing programmatic matchmaking.
Function: (function) request( (string) “startBrowsingForNearbyPlayers” )
Param Table Keys: none
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “nearbyPlayerFound” – Nearby player found event.
Event Properties:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
1 2 3 4 |
-- see gameKit real-time matchmaker events gameKit.request( "startBrowsingForNearbyPlayers" ) |
Request Stop Browsing For Nearby Players
Comments: Programmatically Stop Browsing For Nearby Players through Bluetooth or WiFi on the same subnet.
Function: (function) request( (string) “stopBrowsingForNearbyPlayers” )
Param Table Keys: none
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “success” – GameKit success event.
Event Properties:
(string) successDescription – GameKit success description string.
1 2 3 4 |
-- see gameKit real-time matchmaker events gameKit.request( "stopBrowsingForNearbyPlayers" ) |
Get The Number Of Real-Time Match Requests
Comments: Programmatically Get The Number Of Real-Time Match Requests In The Last 60 Seconds. Note that playerGroup=0 is for all match requests across all player groups.
Function: (function) get( (string) “numberRealTimeMatchRequestsLast60seconds”, (table) { playerGroup= (number) 0 } )
Param Table Keys:
(number) playerGroup – A number identifying a subset of players allowed to join the match. Only players whose requests share the same playerGroup value are auto-matched by Game Center. For more information, see playerGroup in the Matchmaking Overview Guide.
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “error” – GameKit error event.
(string) “matchmakingActivity” – Matchmaking activity within the last 60 seconds event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(number) numberOfPlayers – Number of players that have searched for a match within the last 60 seconds.
1 2 3 4 |
-- see gameKit real-time matchmaker events gameKit.get( "numberRealTimeMatchRequestsLast60seconds" ) |
Request Register Real-Time Listener
Comments: Register Game Center Real-Time game listener for all Real-Time game events. Note you need to register the Real-Time listener before you can call any other Real-Time game functions.
Function: request( (string) “registerRealTimeListener”, (table) { listener= (function) onRealTimeGameCallback } )
Param Table Keys: (function) listener – A function to receive callback events.
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “success” – GameKit success event.
Event Properties:
(string) successDescription – GameKit success description string.
1 2 3 4 |
-- see gameKit real-time matchmaker events gameKit.request( "registerRealTimeListener", { listener=onRealTimeGameCallback } ) |
GameKit Real-Time Game Events
Comments: GameKit Real-Time Game Events called on local player’s device. Note the Real-Time game listener needs to be registered before the local player’s device can receive these events.
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “error” – GameKit error event.
(string) “success” – GameKit success event.
(string) “matchData” – Match data event.
(string) “playerStateDisconnected” – Player state disconnected event.
(string) “playerStateUnknown” – Player state unknown event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(string) successDescription – GameKit success description string.
(string) fromPlayerID – A string player identifier of the player that sent the data.
(string) data – A data string sent by the player. Your game defines its own format for the string data it transmits and receives over the Game Center network.
(string) playerID – A string assigned by Game Center to uniquely identify a player.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
local function onRealTimeGameCallback(event) if( event.type == "error" ) then print( 'onRealTimeGameCallback event.errorCode = ' .. event.errorCode ) print( 'onRealTimeGameCallback event.errorDescription = ' .. event.errorDescription ) elseif( event.type == "success" ) then print( 'onRealTimeGameCallback event.successDescription = ' .. event.successDescription ) elseif( event.type == "matchData" ) then print( 'onRealTimeGameCallback event.fromPlayerID = ' .. event.fromPlayerID ) print( 'onRealTimeGameCallback event.data = ' .. event.data ) elseif( event.type == "playerStateDisconnected" ) then print( 'onRealTimeGameCallback stateDisconnected event.playerID = ' .. event.playerID ) elseif( event.type == "playerStateUnknown" ) then print( 'onRealTimeGameCallback stateUnknown event.playerID = ' .. event.playerID ) end end gameKit.request( "registerRealTimeListener", { listener=onRealTimeGameCallback } ) |
Request Disconnect Real-Time Match
Comments: Disconnect local player from Real-Time Match and unregister Real-Time game listener. Note after you unregister the Real-Time game listener your game will not receive
anymore Real-Time game events and you cannot call any other Real-Time game functions.
Function: request( (string) “disconnectRealTimeMatch” )
Param Table Keys: none
Callback Events: none
1 2 3 |
gameKit.request( "disconnectRealTimeMatch" ) |
Send Real-Time Data To All Players
Comments: Send Real-Time Data To All match Players.
Function: (function) sendRealTimeDataToAllPlayers( (table) { data= (string) “mock-data”, dataMode= (string) “Reliable”, successCallback= (boolean) true } )
Param Table Keys:
(string) data – A data string sent by the local player. Your game defines its own format for the string data it transmits and receives over the Game Center network.
(string) dataMode – A data send mode type string used to transmit data to other players. dataMode=”Reliable” or dataMode=”Unreliable”. “Reliable” (TCP) limits the size of data sent to 87 kilobytes or smaller and transmissions are delivered in the order they were sent. The data is sent continuously until it is successfully received by the intended recipients or the connection times out. Use reliable when you need to guarantee delivery and speed is not critical. “Unreliable” (UDP) limits the size of data sent to 1000 bytes or smaller and transmissions delivered may be received out of order by recipients. Typically, you build your own game-specific error handling on top of this mechanism. The data is sent once and is not sent again if a transmission error occurs. Use this for small packets of data that must arrive quickly to be useful to the recipient.
(boolean) successCallback – A Boolean that indicates whether there is a success callback event or not for data sent successfully to all players.
Callback Events:
(string) “error” – GameKit error event.
(string) “success” – GameKit success event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(string) successDescription – GameKit success description string.
1 2 3 4 5 6 |
mockData = "mock|string-gameData" -- see gameKit real-time matchmaker events gameKit.sendRealTimeDataToAllPlayers( { data=mockData, dataMode="Reliable", successCallback=true } ) |
Send Real-Time Data To Players
Comments: Send Real-Time Data To specific match Players.
Function: (function) sendRealTimeDataToPlayers( (table) { data= (string) “mock-data”, dataMode= (string) “Reliable”, playerIDs= (table) { (string) “G:2073637149” }, successCallback= (boolean) false } )
Param Table Keys:
(string) data – A data string sent by the local player. Your game defines its own format for the string data it transmits and receives over the Game Center network.
(string) dataMode – A data send mode type string used to transmit data to other players. dataMode=”Reliable” or dataMode=”Unreliable”. “Reliable” (TCP) limits the size of data sent to 87 kilobytes or smaller and transmissions are delivered in the order they were sent. The data is sent continuously until it is successfully received by the intended recipients or the connection times out. Use reliable when you need to guarantee delivery and speed is not critical. “Unreliable” (UDP) limits the size of data sent to 1000 bytes or smaller and transmissions delivered may be received out of order by recipients. Typically, you build your own game-specific error handling on top of this mechanism. The data is sent once and is not sent again if a transmission error occurs. Use this for small packets of data that must arrive quickly to be useful to the recipient.
(table) playerIDs – An array of 1 or more playerID strings that the data is to be sent to.
(boolean) successCallback – A Boolean that indicates whether there is a success callback event or not for data sent successfully to players.
Callback Events:
(string) “error” – GameKit error event.
(string) “success” – GameKit success event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(string) successDescription – GameKit success description string.
1 2 3 4 5 6 7 8 9 |
-- mock data, get real playerIDs from Game Center mockPlayerOneID = "G:2073637149" mockPlayerTwoID = "G:9125286970" mockData = "mock|string-gameData" -- see gameKit real-time matchmaker events gameKit.sendRealTimeDataToPlayers( { data=mockData, dataMode="Reliable", playerIDs={mockPlayerOneID, mockPlayerTwoID}, successCallback=false } ) |