Skip to content

Commit

Permalink
skip setKeepAlive if not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
iamchucky committed Jun 3, 2015
1 parent 53d9326 commit 49de0fc
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions socketClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,33 @@ SocketClient.prototype.connect = function() {

// onConnectComplete
// set keepalive with 5 mins delay
chrome.socket.setKeepAlive(self.socketId, self.enableKeepAlive, self.setKeepAlive, function(result) {
if (self.enableKeepAlive) {
if (self.enableKeepAlive) {

chrome.socket.setKeepAlive(self.socketId, self.enableKeepAlive, self.setKeepAlive, function(result) {
console.log('set keepalive with '+self.setKeepAlive+' sec delay');
}

if (result < 0) {
// still connect without keepalive
console.log('socket set keepalive error');
}
if (result < 0) {
// still connect without keepalive
console.log('socket set keepalive error');
}

chrome.socket.read(self.socketId, self._onDataRead.bind(self));
if (self.callbacks.connect) {
//console.log('connect complete');
self.callbacks.connect();
}
});

} else {

// skip set keepalive completely if not enabling
chrome.socket.read(self.socketId, self._onDataRead.bind(self));
if (self.callbacks.connect) {
//console.log('connect complete');
self.callbacks.connect();
}
});

}

});
} else {
Expand Down

0 comments on commit 49de0fc

Please sign in to comment.