Commit 5773def8 authored by martin hou's avatar martin hou

fix: 增加addWakeupListener方法代替onwakeup事件,因为调用时机不对

parent 7936aaed
...@@ -143,6 +143,7 @@ declare class Jensen { ...@@ -143,6 +143,7 @@ declare class Jensen {
// 事件:当连接异常时触发 // 事件:当连接异常时触发
onerror: (e: Error) => void; onerror: (e: Error) => void;
onwakeup: () => void; onwakeup: () => void;
addWakeupListener: (listener: () => void) => void;
// 主动断开连接(单连接时适用) // 主动断开连接(单连接时适用)
disconnect: () => void; disconnect: () => void;
// 事件:当连接断开时触发 // 事件:当连接断开时触发
......
...@@ -173,6 +173,19 @@ function Jensen(log, conn) { ...@@ -173,6 +173,19 @@ function Jensen(log, conn) {
} catch (err) { } catch (err) {
Logger.error('jensen', 'setup', err); Logger.error('jensen', 'setup', err);
} }
};
this.initialize = async function() {
if (conn)
{
if (!conn.opened) conn.open();
await setup();
}
return true;
}
this.addWakeupListener = function(listener) {
this.onwakeup = listener;
Logger.info('jensen', 'hibernate', 'setup'); Logger.info('jensen', 'hibernate', 'setup');
if (self.sleepChecker) window.clearInterval(self.sleepChecker); if (self.sleepChecker) window.clearInterval(self.sleepChecker);
self.sleepChecker = setInterval(function() { self.sleepChecker = setInterval(function() {
...@@ -197,15 +210,6 @@ function Jensen(log, conn) { ...@@ -197,15 +210,6 @@ function Jensen(log, conn) {
} }
self.lastTimerInvoked = now; self.lastTimerInvoked = now;
}, 5000); }, 5000);
};
this.initialize = async function() {
if (conn)
{
if (!conn.opened) conn.open();
await setup();
}
return true;
} }
this.sequence = function() { this.sequence = function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment