// Socket.
this.socketId = null;
this.isConnected = false;
+ this.pollerId = null;
log('initialized tcp client');
}
*/
TcpClient.prototype.disconnect = function() {
socket.disconnect(this.socketId);
+ clearInterval(this.pollerId);
+ this.pollerId = null;
this.isConnected = false;
};
*/
TcpClient.prototype._onConnectComplete = function(resultCode) {
// Start polling for reads.
- setInterval(this.poll.bind(this), 500);
+ clearInterval(this.pollerId);
+ this.pollerId = setInterval(this.poll.bind(this), 500);
if (this.callbacks.connect) {
log('connect complete');