次のコードでは、接続が成功したときに onSuccess がコールバックされていません。一連のイベントのコードとログ出力をリストしました。コードの設定が間違っていませんか?initOptions で connectOnStartup が false に設定されています。このコードはシェル プロジェクトにもあり、logcat はシェルを使用して内部プロジェクトから取得されます。
function onConnectSuccess(){
console.log ("CSXMobile:onConnectSuccess");
WL.Logger.debug("CSXMobile:onConnectSuccess");
}
function onConnectFailure(){
WL.Logger.debug("CSXMobile:onConnectFailure");
}
function disconnectDetected(){
WL.Logger.debug("CSXMobile:disconnectDetected");
}
function connectDetected(){
WL.Logger.debug("CSXMobile:connectDetected");
}
function wlCommonInit(){
WL.Logger.debug("CSXMobile:wlCommonInit");
document.addEventListener(WL.Events.WORKLIGHT_IS_CONNECTED, connectDetected, false);
document.addEventListener(WL.Events.WORKLIGHT_IS_DISCONNECTED, disconnectDetected , false);
WL.Client.connect({
onSuccess: onConnectSuccess,
onFailure: onConnectFailure
});
}
ここのログに見られるように、wlCommonInit が呼び出されてログに記録されていますが、onConnectSuccess のログ ステートメントは決して書き込まれません...
11-21 13:49:01.460: D/CSXMobileShellTest(6341): wlclient init started
11-21 13:49:01.460: D/CSXMobileShellTest(6341): Read cookies: null
11-21 13:49:01.460: D/CSXMobileShellTest(6341): CookieMgr read cookies: {}
11-21 13:49:01.507: D/dalvikvm(6341): GC_CONCURRENT freed 311K, 4% free 11407K/11783K, paused 2ms+16ms, total 34ms
11-21 13:49:01.507: D/CordovaNetworkManager(6341): Connection Type: wifi
11-21 13:49:01.507: D/DroidGap(6341): onMessage(networkconnection,wifi)
11-21 13:49:01.507: D/DroidGap(6341): onMessage(spinner,stop)
11-21 13:49:01.507: D/CordovaLog(6341): CSXMobile:csxmobileDeviceReady
11-21 13:49:01.507: I/Web Console(6341): CSXMobile:csxmobileDeviceReady at file:///data/data/com.csx.CSXMobileShellTest/files/www/default/js/CSXMobile.js:172
11-21 13:49:01.538: D/CSXMobileShellTest(6341): CSXMobile:deviceOnline
11-21 13:49:01.546: D/CSXMobileShellTest(6341): before: app init onSuccess
11-21 13:49:01.546: D/CSXMobileShellTest(6341): CSXMobile:wlCommonInit
11-21 13:49:01.561: D/CSXMobileShellTest(6341): Request [https://myworklightserver/query]
11-21 13:49:01.585: D/CSXMobileShellTest(6341): after: app init onSuccess
11-21 13:49:01.585: D/CSXMobileShellTest(6341): added onPause event handler
11-21 13:49:01.585: D/CSXMobileShellTest(6341): wlclient init success
11-21 13:49:01.858: D/CSXMobileShellTest(6341): isCustomResponse
11-21 13:49:01.858: D/CSXMobileShellTest(6341): isCustomResponse true
11-21 13:49:01.858: D/CSXMobileShellTest(6341): handleChallenge
11-21 14:14:57.796: D/DroidGap(6656): onMessage(spinner,stop)
11-21 14:15:08.975: D/CSXMobileShellTest(6656): Request [login]
11-21 14:15:09.132: D/CSXMobileShellTest(6656): Status =401
11-21 14:15:09.132: D/CSXMobileShellTest(6656): isCustomResponse
11-21 14:15:09.139: D/CSXMobileShellTest(6656): isCustomResponse false
11-21 14:15:09.147: D/CSXMobileShellTest(6656): Request [https://myworklightserver/query]
11-21 14:15:09.163: D/CSXMobileShellTest(6656): hideLogin
11-21 14:15:09.413: D/Cordova(6656): onPageFinished(file:///data/data/com.csx.CSXMobileShellTest/files/www/default/CSXMobileShellTest.html#testMainPage)
11-21 14:15:09.413: D/Cordova(6656): Trying to fire onNativeReady
11-21 14:15:09.413: D/DroidGap(6656): onMessage(onNativeReady,null)
11-21 14:15:09.413: D/DroidGap(6656): onMessage(onPageFinished,file:///data/data/com.csx.CSXMobileShellTest/files/www/default/CSXMobileShellTest.html#testMainPage)
11-21 14:15:09.475: D/CSXMobileShellTest(6656): Request [https://myworklightserver/query]
11-21 14:15:09.522: D/CSXMobileShellTest(6656): Request [https://myworklightserver/query]
11-21 14:15:09.616: D/CSXMobileShellTest(6656): isCustomResponse
11-21 14:15:09.616: D/CSXMobileShellTest(6656): isCustomResponse false
11-21 14:15:09.616: D/CSXMobileShellTest(6656): CSXMobile:connectDetected
11-21 14:15:09.647: D/CSXMobileShellTest(6656): response [https://myworklightserver/query] success: /*-secure-