ibm-mobilefirstmobilefirst-runtime

MobileFirst Platform Foundation 7.0 event listeners not working properly


I upgraded a simple hybrid Worklight project from 6.3 to 7.0. The majority of functionality is fine. However, listeners for WL.Events.WORKLIGHT_IS_CONNECTED and WL.Events.WORKLIGHT_IS_DISCONNECTED no longer function properly.

Here is the code:

    function wlCommonInit(){

        WL.Client.connect({onSuccess: onConnectSuccess, onFailure: onConnectFailure});

        function onConnectSuccess() {
            WL.Logger.debug("Connect success.");
        }

        function onConnectFailure() {
            WL.Logger.debug("Connect failed.");
        }

        $("body").resize();

        //Added listeners for Online/Offline functionality and set heart beat
        document.addEventListener(WL.Events.WORKLIGHT_IS_CONNECTED, connectDetected, false); 
        document.addEventListener(WL.Events.WORKLIGHT_IS_DISCONNECTED, disconnectDetected , false);
        WL.Client.setHeartBeatInterval(10);

        initJson();
    }

// Online/Offline Functions
function connectionFailure(){
    alert("Could not connect to the MobileFirst Server.");
    var output = "OFFLINE";
    $('#ConnectionMsg').html(output);
}

function disconnectDetected(){
    var output = "<font color='red'>DISCONNECTED</font>";
    $('#ConnectionMsg').html(output);
}

function connectDetected(){
    var output = "<font color='green'>CONNECTED</font>";
    $('#ConnectionMsg').html(output);
    if(initialConnection){
        initialConnection = false;
    } else {
        setTimeout(function(){
            //cleanDirtyDocs();
        }, 20000);
    }
}

Simply, the application has a footer that says "CONNECTED" or "DISCONNECTED" based on the WORKLIGHT_IS_CONNECTED and WORKLIGHT_IS_DISCONNECTED events. This works perfectly in WL6.3, but the exact same code does not work in 7.0. There is no message after initialization, just a blank footer, and the only way to get DISCONNECT to display is to call an adapter after the server is down. CONNECT is never displayed.

This makes no sense and is easy to replicate. Was there a change in how these events work? Thanks!


Solution

  • This is a known issue with the MFP v7.0 release. an iFix release is planned to address it. At this time there is no workaround.

    Please open a PMR (support ticket) so that the fix could be delivered to you.
    You can mention "APAR PI38012" for the support team to find it.