All Functions Modules Pages
adhoc

Functions

NUMBER adhoc.init ()
 Initialize Adhoc module. More...
 
NUMBER adhoc.init (STRING gameid)
 Initialize Adhoc module. More...
 
STRING adhoc.getmac ()
 Obtain physical address (MAC) of our console. More...
 
TABLE adhoc.scan ()
 Obtain a list of available PSP consoles to successfully make an adhoc connection. More...
 
NUMBER adhoc.gettotal ()
 Allows to know the number of the remote PSP available. More...
 
BOOLEAN adhoc.sendrequest (NUMBER index)
 Request connection to a remote PSP for a time lapse of 30 seconds. More...
 
BOOLEAN adhoc.sendrequest (NUMBER index, NUMBER timeout)
 Request connection to a remote PSP. More...
 
TABLE adhoc.getrequest ()
 Allow to know which PSP requested a connection. More...
 
NIL adhoc.accept (NUMBER index)
 Accept connection request. More...
 
NIL adhoc.reject (NUMBER index)
 Rejects connection request. More...
 
NUMBER adhoc.send (NUMBER index, STRING data)
 Send data to a Remote PSP (when accepted or successfully connection). More...
 
NUMBER adhoc.send (NUMBER index, STRING data, NUMBER size)
 Send data to a Remote PSP (when accepted or successfully connection). More...
 
STRING adhoc.recv (NUMBER index, NUMBER size)
 Allow to receive data from a Remote PSP (when accepted or successfully connection). More...
 
NIL adhoc.term ()
 Finalizes adhoc module. More...
 

Detailed Description

Adhoc functions.

Function Documentation

NUMBER adhoc.init ( )

Initialize Adhoc module.

Returns
A number, showing the result of the connection: 1 if the connection was successful, 0 otherwise
NUMBER adhoc.init ( STRING  gameid)

Initialize Adhoc module.

Parameters
gameidThis is the gameid to be shown as an identifier in the adhoc mode (Maximum 9 characters and must be uppercase).
Returns
A number, showing the result of the connection: 1 if the connection was successful, 0 otherwise
STRING adhoc.getmac ( )

Obtain physical address (MAC) of our console.

Returns
MAC address in format: XX:XX:XX:XX:XX:XX
TABLE adhoc.scan ( )

Obtain a list of available PSP consoles to successfully make an adhoc connection.

Returns
A table with those fields:
  • name: Name of the remote PSP (Nick).
  • mac: MAC address of the remote PSP.
  • state: Current status of the remote PSP. The numerical value into parentheses.
    • __JOINED (1) A remote PSP has joined.
    • __SELECTED (2) A remote PSP has selected me.
    • __REJECTED (4) Request rejected.
    • __CANCELED (5) Request cancelled.
    • __ACCEPTED (6) Request accepted.
    • __ESTABLISHED (7) Connection established.
    • __DISCONNECTED (10) A PSP has been disconnected.
NUMBER adhoc.gettotal ( )

Allows to know the number of the remote PSP available.

Returns
Total number of remote PSP available.
BOOLEAN adhoc.sendrequest ( NUMBER  index)

Request connection to a remote PSP for a time lapse of 30 seconds.

Parameters
indexindex obtained from the adhoc.scan() table.
Note
This function allows to use the callback onAdhocConnection(), more info here .
Returns
true As if the connection was accepted / established or False otherwise.
BOOLEAN adhoc.sendrequest ( NUMBER  index,
NUMBER  timeout 
)

Request connection to a remote PSP.

Parameters
indexindex obtained from the adhoc.scan() table.
timeout(optional) time limit which the application will remain the connection opened. Default to 30 seconds if there is no value.
Note
This function allows to use the callback onAdhocConnection(), more info here .
Returns
true/false As if the connection was accepted / established or rejected.
TABLE adhoc.getrequest ( )

Allow to know which PSP requested a connection.

Returns
Una tabla con el PSP remoto que ha enviado una solicitud.
  • name: Nombre del PSP remoto (Nick).
  • mac: Es la dirección mac del PSP remoto.
  • state: Es el estado actual del PSP remoto. En paréntesis el valor numérico.
    • __JOINED (1) A remote PSP has joined.
    • __SELECTED (2) A remote PSP has selected me.
    • __REJECTED (4) Request rejected.
    • __CANCELED (5) Request cancelled.
    • __ACCEPTED (6) Request accepted.
    • __ESTABLISHED (7) Connection established.
    • __DISCONNECTED (10) A PSP has been disconnected.
NIL adhoc.accept ( NUMBER  index)

Accept connection request.

Parameters
indexIndex of the PSP which request connection.
Returns
Nothing.
NIL adhoc.reject ( NUMBER  index)

Rejects connection request.

Parameters
indexIndex of the PSP which request connection.
Returns
Nothing.
NUMBER adhoc.send ( NUMBER  index,
STRING  data 
)

Send data to a Remote PSP (when accepted or successfully connection).

Parameters
indexIndex of the PSP which you want to send data or message.
dataString with the message or text.
Returns
The number of bytes sent.
NUMBER adhoc.send ( NUMBER  index,
STRING  data,
NUMBER  size 
)

Send data to a Remote PSP (when accepted or successfully connection).

Parameters
indexIndex of the PSP which you want to send data or message.
dataString with the message or text.
sizeSize data to be sending.
Returns
The number of bytes sent.
STRING adhoc.recv ( NUMBER  index,
NUMBER  size 
)

Allow to receive data from a Remote PSP (when accepted or successfully connection).

Parameters
indexIndex of the PSP which you want to receive data or messages.
sizeSize data to be received for save them in buffer. Default to 1024 if there is no value.
Returns
The data plus the number of bytes received.
NIL adhoc.term ( )

Finalizes adhoc module.

Returns
nothing.