MultipeerModule Class
Item Index
Constants
- ENCRYPTION_NONE
- ENCRYPTION_OPTIONAL
- ENCRYPTION_REQUIRED
- ERROR_CANCELLED
- ERROR_INVALID_PARAMETER
- ERROR_NOT_CONNECTED
- ERROR_TIMED_OUT
- ERROR_UNAVAILABLE
- ERROR_UNKNOWN
- ERROR_UNSUPPORTED
- MAX_PEER_COUNT
- MIN_PEER_COUNT
- SEND_MODE_RELIABLE
- SEND_MODE_UNRELIABLE
- SESSION_STATE_CONNECTED
- SESSION_STATE_CONNECTING
- SESSION_STATE_NOT_CONNECTED
Events
Methods
createAdvertiserAssistant
-
params
Creates an AdvertiserAssistant object.
Parameters:
-
params
Object-
serviceType
StringThe service type to browse for. Must be 1–15 characters long and can contain only ASCII lowercase letters, numbers, and hyphens.
This name should be easily distinguished from unrelated services. For example, a text chat app made by ABC company could use the service type abc-txtchat.
-
session
SessionThe session to connect the peers to.
-
[discoveryInfo]
Object optionalA dictionary of key-value pairs that are made available to browsers. Each key and value must be a string. This data is advertised using a Bonjour TXT record, encoded according to RFC 6763 (section 6). As a result, the key-value pair must be no longer than 255 bytes (total) when encoded in UTF-8 format with an equals sign (=) between the key and the value, and keys cannot contain an equals sign.
For optimal performance, the total size of the keys and values in this dictionary should be no more than about 400 bytes so that the entire advertisement can fit within a single Bluetooth data packet.
-
Returns:
createPeer
-
params
Creates a Peer object.
Parameters:
-
params
Object-
name
StringName of the peer.
-
Returns:
hidePicker
()
Void
Dismisses the built-in peer browser view.
See also the showPicker function and the pickerCancel and pickerDone events.
Returns:
showPicker
-
params
Opens the built-in peer browser view. This view will show the nearby peers and allow the user to connect to one or more of them.
See also the hidePicker function and the pickerCancel and pickerDone events.
Parameters:
-
params
Object-
serviceType
StringThe service type to browse for. Must be 1–15 characters long and can contain only ASCII lowercase letters, numbers, and hyphens.
This name should be easily distinguished from unrelated services. For example, a text chat app made by ABC company could use the service type abc-txtchat.
-
session
SessionThe session to connect the peers to.
-
[animated]
Boolean optionalWhether or not the view should be displayed and dismissed in an animated fashion.
-
[autoHide]
Boolean optionalWhether or not the view should be automatically dismissed when the user taps Cancel or Done.
-
[maxPeerCount]
Number optionalThe maximum number of peers allowed in a session, including the local peer. Defaults to 8.
-
[minPeerCount]
Number optionalThe minimum number of peers that need to be in a session, including the local peer. Defaults to 2.
-
Returns:
Constants
ENCRYPTION_NONE
Number
Indicates whether a session should use encryption when communicating with nearby peers.
ENCRYPTION_OPTIONAL
Number
Indicates whether a session should use encryption when communicating with nearby peers.
ENCRYPTION_REQUIRED
Number
Indicates whether a session should use encryption when communicating with nearby peers.
Events
pickerCancel
Fired when the user taps the Cancel button on the built-in peer browser view.
See also the showPicker and hidePicker functions and the pickerDone event.
pickerDone
Fired when the user taps the Done button on the built-in peer browser view.
See also the showPicker and hidePicker functions and the pickerCancel event.