Esempio n. 1
0
Ftp.prototype.keepAlive = function() {
  var self = this;
  if (this._keepAliveInterval)
    vertx.cancelTimer(this._keepAliveInterval);

  this._keepAliveInterval = vertx.setPeriodic(IDLE_TIME, function () { self.raw.noop(); });
};
Esempio n. 2
0
 smtpClient.once('idle', function () {
     if (sendTimeoutTimer) {
         vertx.cancelTimer(sendTimeoutTimer);
     }
     self._isIdle = true;
     callback(undefined, sendResult);
 });
Esempio n. 3
0
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) {}
};
Esempio n. 4
0
 /*
  * 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
Esempio n. 5
0
    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));
        }
    });
Esempio n. 6
0
 smtpClient.on('end', function () {
     if (sendTimeoutTimer) {
         vertx.cancelTimer(sendTimeoutTimer);
     }
     callback(sendError, sendResult);
 });