DeviceService Class
Provides possibility to activate/deactivate device, to show device settings on connector, and to track availability of device.
Constructor
DeviceService
()
Item Index
Methods
addAvailabilityChangedListener
(
Void
-
handler
Adds listeners to AvailabilityChanged event.
Parameters:
-
handler
FunctionA function that handles the event. The function that has a single parameter of boolean type and does not return a value.
Returns:
Void:
Example:
var connector = new buildingLink.Connector();
// Handles AvailabilityChanged event.
var onAvailabilityChanged = function(isAvailable) {
alert("Service availability changed: " + isAvailable);
};
var connectionSuccededCallback = function() {
// Adds listener to AvailabilityChanged event for any service: connector.barcodeScanService.addAvailabilityChangedListener(), connector.fingerprintReaderService.addAvailabilityChangedListener().
connector.idCardScanService.addAvailabilityChangedListener(onAvailabilityChanged);
};
var connectionClosedCallback = function(connectionError) {
alert("Connection failed."); // Shows connection failure message.
};
connector.activate(connectionSuccededCallback, connectionClosedCallback);
getIsAvailableAsync
()
Promise | Boolean
async
Allows to determine whether device is available.
Returns:
Promise | Boolean:
A promise of the result that returns true if device is available or false otherwise in case of success.
Example:
var connector = new buildingLink.Connector();
var connectionSuccededCallback = function() {
// Gets whether device service is available or no. This method is common for all services and can be used like: connector.autoDialerService.getIsAvailableAsync(), connector.fingerprintReaderService.getIsAvailableAsync(), etc.
connector.webCameraService.getIsAvailableAsync().then(function (isAvailable) {
if (isAvailable) {
alert("Service is available.");
} else {
alert("Service is not available.");
}
});
};
var connectionClosedCallback = function(connectionError) {
alert("Connection failed."); // Shows connection failure message.
};
connector.activate(connectionSuccededCallback, connectionClosedCallback);
removeAvailabilityChangedListener
(
Void
-
handler
Removes listeners from AvailabilityChanged event.
Parameters:
-
handler
FunctionA function that handles the event. The function that has a single parameter of boolean type and does not return a value.
Returns:
Void:
Example:
var connector = new buildingLink.Connector();
// Handles AvailabilityChanged event.
var onAvailabilityChanged = function(isAvailable) {
alert("Service availability changed: " + isAvailable);
};
var connectionSuccededCallback = function() {
// Adds listener to AvailabilityChanged event for any service: connector.signaturePadService.addAvailabilityChangedListener(), connector.autoDialerService.addAvailabilityChangedListener().
connector.idCardScanService.addAvailabilityChangedListener(onAvailabilityChanged);
// Removes AvailabilityChanged listener in 5 seconds for any service: connector.signaturePadService.removeAvailabilityChangedListener(), connector.autoDialerService.removeAvailabilityChangedListener().
setTimeout(function (){
connector.idCardScanService.removeAvailabilityChangedListener(onAvailabilityChanged);
alert("AvailabilityChanged listener."); // Observe that notifications will be stopped after this alert.
}, 5000);
};
var connectionClosedCallback = function(connectionError) {
alert("Connection failed."); // Shows connection failure message.
};
connector.activate(connectionSuccededCallback, connectionClosedCallback);
showSettingsAsync
()
Promise | Void
async
Allows to show device settings in Connector app.
Returns:
Promise | Void:
A promise of the result.
Example:
var connector = new buildingLink.Connector();
var connectionSuccededCallback = function() {
// Shows device settings for selected service. This method is common for all services and can be used: connector.idCardScanService.showSettingsAsync(), connector.barcodeScanService.showSettingsAsync(), etc.
connector.printService.showSettingsAsync();
};
var connectionClosedCallback = function(connectionError) {
alert("Connection failed."); // Shows connection failure message.
};
connector.activate(connectionSuccededCallback, connectionClosedCallback);