PlayerIO

The fastest way to build online games without breaking a sweat.

HTML5 (Javascript) Client Reference

javascript (html5) gameRequests class informationClass gameRequests

Language: Javascript (HTML5)

The GameRequest service. This class has methods for sending game requests to other users, and for handling the requests received by the current user. All game request types have to be defined in the admin panel first.

Example

Refresh local requests

Example

Send a game request to another player

Example

Delete all waiting requests

Properties

 
waitingRequests :gameRequest[]

The list of waiting requests for the current user. You must call refresh() first to initialize this list.

Methods

 
delete (requests, successCallback, errorCallback):

Delete the given requests. Will also update the waitingRequests property after deletion is complete.

refresh (successCallback, errorCallback):

Refresh the list of received requests.

send (requestType, requestData, requestRecipients, successCallback, errorCallback):

Send a GameRequest to the specified recipients.

gameRequests.waitingRequests

waitingRequests :gameRequest[]

The list of waiting requests for the current user. You must call refresh() first to initialize this list.

gameRequests.delete

delete (requests, successCallback, errorCallback):

Delete the given requests. Will also update the waitingRequests property after deletion is complete.

Arguments

requests:gameRequest[]
The list of requests to delete.
successCallback:function()
Callback function that will be called when the delete has been completed.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.

gameRequests.refresh

refresh (successCallback, errorCallback):

Refresh the list of received requests.

Arguments

successCallback:function()
Callback function that will be called when the refresh is complete
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs

gameRequests.send

send (requestType, requestData, requestRecipients, successCallback, errorCallback):

Send a GameRequest to the specified recipients.

Arguments

requestType:number
The request type of the request to send.
requestData:object
Data that will be available to the recipient of the request with information about the request. Useful for passing any kind of data to the recipient.
requestRecipients:string[]
The recipients to send this request to.
successCallback:function()
Callback function that will be called when the request has been sent.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.