Connection

Connection API is for connection between FrameworkJS and CloadIO for transferring data and information.

app.onOpened()

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 () {};

  • Example
    Performing an onOpened function configuration inside the app.js:
    // on connection open event
    app.onOpened = function () {
        alert('The internet is connected.');
    };

app.onClosed()

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 () {};

  • Example
    Performing an onClosed function configuration inside the app.js:
    // on connection close event
    app.onClosed = function () {
        alert('The connection was lost.');
    };

app.onConnected()

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) {};

  • Detail

    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.
  • Example
    Performing an onConnected function configuration inside the app.js:
    // 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();
        }
    };