Ftp.prototype.keepAlive = function() { var self = this; if (this._keepAliveInterval) vertx.cancelTimer(this._keepAliveInterval); this._keepAliveInterval = vertx.setPeriodic(IDLE_TIME, function () { self.raw.noop(); }); };
smtpClient.once('idle', function () { if (sendTimeoutTimer) { vertx.cancelTimer(sendTimeoutTimer); } self._isIdle = true; callback(undefined, sendResult); });
Ftp.prototype.destroy = function() { try { if (this._keepAliveInterval) vertx.cancelTimer(this._keepAliveInterval); this.removeAllListeners(); if (this.socket) this.socket.close(); this.socket = undefined; this.features = null; this.authenticated = false; } catch (ignore) {} };
/* * Reusable function to return and error */ function returnError (err) { if (sendTimeoutTimer) { vertx.cancelTimer(sendTimeoutTimer); } if (smtpClient) { try { smtpClient.close(); } catch (ignore) {} smtpClient = undefined; } callback(err); } // END: returnError
vertx.setPeriodic(1, function(id){ //console.log('Periodic ' + count); count++; var bytes = port.getQueueStatus(); //console.log('Per '+ count + ', Bytes ' + bytes); if(locked){ if(bytes >= 747) { var buffer = port.read(bytes); } // TODO: Change to actual readed buffer length if(bytes == 747){ trueCount++; console.log('Pkt: ' + trueCount); // port.write('123'); } else { if(bytes > 747){ locked = false; proe++; console.log('Proe: ' + proe); console.log('Bytes: ' + bytes); console.log('Curr: ' + trueCount); } } } else { if(bytes > 0) { console.log('Not locked, reading ' + bytes + ' bytes'); port.read(bytes); } else { locked = true; console.log('Buffer is empty. Locking alrogithm'); } } if(count === 100000) { vertx.cancelTimer(id); console.log('Done: ' + (count/trueCount) + ' ms'); console.log('Proe: ' + proe); console.log('TrueCounts: ' + trueCount); console.log('%: ' + (proe/trueCount*100)); } });
smtpClient.on('end', function () { if (sendTimeoutTimer) { vertx.cancelTimer(sendTimeoutTimer); } callback(sendError, sendResult); });