Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup event proxy and socket sending

  • Loading branch information...
commit af5aafe15fe52489447070b26eb89afc2c933fee 1 parent ead6abb
@kennethkalmer kennethkalmer authored committed
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/smtp/server.js
View
15 lib/smtp/server.js
@@ -93,8 +93,10 @@ SMTPSession.prototype.events = [
// Replies
SMTPSession.prototype.send = function( s ) {
- sys.print("SENDING: " + s + eol);
- this.socket.send( s + eol );
+ if( this.socket.readyState == 'open' ) {
+ sys.print("SENDING: " + s + eol);
+ this.socket.send( s + eol );
+ }
}
SMTPSession.prototype.greeting = function() {
@@ -232,14 +234,15 @@ Server.prototype.runServer = function() {
var session = new SMTPSession();
// Only add listeners to the session if folks are listening to us.
- for( var i = 0; i < session.events.length; i++ ) {
- var e = session.events[i];
+ session.events.forEach( function( e ) {
if( self.listeners( e ).length > 0 ) {
+ var ev = e;
session.addListener( e, function() {
- self.emit( e, arguments);
+ sys.puts('emit-by-proxy: ' + ev );
+ self.emit( ev, arguments );
});
}
- }
+ });
session.connect( socket );
Please sign in to comment.
Something went wrong with that request. Please try again.