Connection API is for connection between FrameworkJS and CloadIO for transferring data and information.
The app.onOpened
event is called when the internet connection opened. It means can handle the codes when are connecting to internet.
Type:
Function
app.onOpened = function () {};
// on connection open event
app.onOpened = function () {
alert('The internet is connected.');
};
The app.onClosed
is called when internet connection closed. For instance, you can handle connection codes when the internet lost.
Type:
Function
app.onClosed = function () {};
// on connection close event
app.onClosed = function () {
alert('The connection was lost.');
};
Called when a new connection has been established. In this event, user and time are not synced yet.
Type:
Function
app.onConnected = function (error, credential) {};
app.onConnected
has two entry argument, the first one is error handling, and the another is for user certificate.
Parameters | Type | Description |
---|---|---|
error | String | The callback error of checking authorization. |
credential | String | The string of credentials on checking authorization and user certificate. |
// on connection open for first time event
app.onConnected = function (error, credential) {
// check credential
if (localStorage['authentication'] === 'completed') {
if (error)
console.error('getting credential failed', error);
if (!credential)
app.auth.clear();
}
};