# Modules.Bluetooth.BluetoothServerSocket

A listening Bluetooth socket.

Availability
1.0.0

# Overview

The purpose of the BluetoothSocketServer object is to listen for incoming connection requests and provide a connected BluetoothSocket after a request is accepted.

# Methods

# close

Availability
1.0.0
close() void

Closes the server socket.

This method, when called, closes the server socket. One cannot start accepting connections again after calling this method. On error, this method will throw an exception.

Returns

Type
void

# isAccepting

Availability
1.0.0
isAccepting() Boolean

Determines whether the server socket is currently accepting connections.

Returns

True if the server socket is accepting connections, false otherwise.

Type
Boolean

# startAccept

Availability
1.0.0
startAccept([keepListening]) void

Inform the server socket to start accepting incoming connections.

This method, when called, starts listening for the incoming Bluetooth connections and block until a connection is established. Listen for the connectionReceived event to be notified when a connection is received or the error event when an error occured during accepting connection.

Parameters

Name Type Description
keepListening Boolean

Defines whether the server socket should keep listening after an incoming connection was received. If this parameter is false, it will stop accepting connections after a single connection is recieved.

Returns

Type
void

# stopAccept

Availability
1.0.0
stopAccept() void

Inform the server socket to stop accepting incoming connections.

This method, when called stop accepting incoming connections. One can again start accepting connections via startAccept method after calling this method. On error, this method will throw an exception.

Returns

Type
void

# Events

# connectionReceived

Availability
1.0.0

Fired when the server socket receives an incoming connection.

Properties

Name Type Description
socket Modules.Bluetooth.BluetoothSocket

The socket object bind to the connection.

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.


# error

Availability
1.0.0

Fired when a socket operation fails.

Properties

Name Type Description
errorMessage String

Description of the error.

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.