Advertiser Class
Objects of this class publish an advertisement for a specific service that your app provides and notifies your app about invitations from nearby peers.
Before you can advertise a service, you must create a Peer object that identifies your app and the user to nearby devices.
Item Index
Methods
Properties
Events
Methods
inviteResponse
-
params
Call this method after you received a receivedInvite event to accept or reject an invitation.
Parameters:
-
paramsObject-
inviteIdNumberThe ID of the invite you are responding to.
-
acceptBooleantrueif you wish to accept the invite,falseotherwise. -
sessionSessionThe session with which to associate the peer that sent the invitate.
-
Returns:
start
()
Void
Begins advertising the service provided by a local peer.
Returns:
stop
()
Void
Stops advertising the service provided by a local peer.
Returns:
Properties
discoveryInfo
Object
read-only
The discoveryInfo passed when this Advertiser was created.
serviceType
String
read-only
The service type that your app is advertising.
Events
error
This event is fired if something goes wrong with the advertising.
Event Payload:
-
errorCodeNumberThe error code.
-
errorDomainStringThe error domain.
-
errorDescriptionStringThe error description.
receivedInvite
This event is fired when an invite is received from a remote peer. You must call the inviteResponse function in response to this event to accept or reject the invitation.
Event Payload:
-
remotePeerPeerThe peer sending the invite.
-
contextTiBufferThe context received with the invite. May be null.
-
inviteIdNumberAn integer that identifies the invite. Use this when calling the inviteResponse function to accept or reject the invitation.
