我已从以下链接导入示例。
我在wlCommonInit()
中添加了一个WL.Client.connect()当我启动应用程序时,控件按以下顺序流动。
WL.Logger.debug("I am inside the WL Common Init");
Registeres the WL.Events.
WL.Logger.debug("connectDetected called");
WL.Logger.debug("Inside the connect-onSuccess");
但是当调用setHeartBeatInterval()方法时。它没有调用connectDetected()方法agin?
有人可以帮我理解为什么在调用setHeartBeatInterval()之后它没有调用connectDetected()方法?
function wlCommonInit(){
WL.Client.connect({
onSuccess: onConnectSuccess,
onFailure: onConnectFailure
});
function onConnectSuccess() {
WL.Logger.debug("Inside the connect-onSuccess");
}
function onConnectFailure() {
WL.Logger.debug("Inside the connect-onFailure");
}
WL.Logger.debug("I am inside the WL Common Init");
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(){
WL.Logger.debug("connectDetected called");
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);
}
答案 0 :(得分:0)
您希望什么时候再打电话?
关闭服务器并再次启动它,它将检测到与服务器的连接,然后它将被调用。