BluetoothServerSocket Class
BluetoothServerSocket objects can be created by calling the createServerSocket function on the BluetoothModule object.
Methods
close
()
Void
Closes the server socket.
Returns:
isAccepting
()
Boolean
Returns true if the server socket is currently accepting connections, false otherwise.
Returns:
True if the server socket is currently accepting connections, false otherwise.
startAccept
-
param
Instructs the server socket to start accepting incoming connections.
Parameters:
-
param
Object-
[keepListening=true]
Boolean optionalDefines whether the server socket should keep listening after an incoming connection was received. The default is
true
. If you set this parameter tofalse
, make sure that you implement an event handler for error events and call the startAccept function as appropriate, because the server socket will stop listening even if the incoming connection fails subsequently.
-
Returns:
stopAccept
()
Void
Instructs the server socket to stop accepting incoming connections.
Returns:
Events
connectionReceived
Fired when the server socket receives an incoming connection.
Event Payload:
-
socket
BluetoothSocketThe socket object tied to the connection.
error
Fired when a socket operation fails.
Event Payload:
-
errorMessage
String