How can I stop all process if network connectivity lost in Smartface.io

134 Views Asked by At

I'm using

function Global_Events_OnStart(e) {
    isNetworkUp = (Device.connectionType == 0);
}

to detect if network connected. At Home Screen's onShow event which hosts code to run Webclients:

function pgHome_Self_OnShow() {
    if (isNetworkUp) {
       wcPersonList.run(true);  // async run
       wcImages.run(true);
    }else{
        Dialogs.dlConnectionWarning.show();
    }
}

Is this ok? Or should I add additional controls to Global Application.onError event?

1

There are 1 best solutions below

1
On BEST ANSWER

With using isNetworkUp control you can use your own Error Dialog.

If you don't write any codeLines to detect that network is up or down,

It triggers Global_Events_OnError .

function Global_Events_OnError(e) {
    switch (e.type) {
    case "Server Error":
    case "Size Overflow":
        alert(lang.networkError);
        break;
    default:
        SES.Analytics.eventLog("error", JSON.stringify(e));
        //change the following code for desired generic error messsage
        alert({
            title : lang.applicationError,
            message : e.message + "\n\n*" + e.sourceURL + "\n*" + e.line + "\n*" + e.stack
        });
        break;
    }
}

Global_Events_OnError is predefined function to detect any kind of error in your project.

Smartface.io Team