Commit be5030e2ed2d7b137e38924212c28648cfb47b58

Authored by Adhidarma Hadiwinoto
1 parent 18e732c088
Exists in master

logout before relogin

Showing 1 changed file with 13 additions and 4 deletions Side-by-side Diff

... ... @@ -78,15 +78,24 @@ function sendMessage(destination, msg, requestId) {
78 78 catch(e) {
79 79 logger.warn(__filename + ': Exception on sending message: ' + e, {e: e, destination: destination, msg: msg, requestId: requestId});
80 80 logger.info('Trying to relogin to YM in 3 secs');
81   -
82   - isOnline = false;
  81 +
  82 + logout();
  83 +
83 84 setTimeout(
84   - YM.newInstance,
85   - 3000
  85 + init,
  86 + 3000,
  87 + username, password, logger, callbacks
86 88 );
87 89 }
88 90 }
89 91  
  92 +function logout(){
  93 + isOnline = false;
  94 + try {
  95 + YM.logout();
  96 + } catch(e) {}
  97 +}
  98 +
90 99 exports.init = init;
91 100 exports.sendMessage = sendMessage;
92 101 exports.isOnline = isOnline;