MFP 8.0迁移| WL.Client.setHeartBeatInterval函数不起作用

时间:2017-08-23 09:27:37

标签: cordova ibm-mobilefirst

我从以下网址下载了一个MFP 6.3示例项目并迁移到MFP 8.0

https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/6.3/working-offline/working-offline/

function wlCommonInit(){    
    document.addEventListener(WL.Events.WORKLIGHT_IS_CONNECTED, connectDetected, false); 
    document.addEventListener(WL.Events.WORKLIGHT_IS_DISCONNECTED, disconnectDetected , false);
}

function connectionFailure(){
    alert("Could not connect to the MobileFirst Server.");
    var output = new Date() + "<hr />Working offline";
    $('#info').html(output);
}

function disconnectDetected(){
    var output = new Date() + "<hr />disconnectDetected";
    $('#info').html(output);
}

function connectDetected(){
    var output = new Date() + "<hr />connectDetected";
    $('#info').html(output);
}

function setHeartBeatInterval(interval){
    var output = new Date() + "<hr />heartbeat interval is set to: " + interval;
    $('#info').html(output);
    WL.Client.setHeartBeatInterval(interval);
}
调用

WL.Client.setHeartBeatInterval函数。但是在MFP 8.0中未触发WORKLIGHT_IS_CONNECTED, WORKLIGHT_IS_DISCONNECTED个事件。

WL.Client.setHeartBeatInterval是否有效?

1 个答案:

答案 0 :(得分:0)

WL.Client.setHeartBeatInterval  从MFP 8.0开始有效,并且运行良好.API详细信息here

但事件不再有效。您可以添加自定义事件侦听器并检查连接。