Permalink
Browse files

emit quit and reset events

  • Loading branch information...
1 parent 095c0d1 commit 44d967db3be4aab5d9f23f9f8247bd4a3556552c @substack committed Nov 30, 2011
Showing with 16 additions and 2 deletions.
  1. +8 −0 README.markdown
  2. +2 −0 lib/client/proto.js
  3. +1 −1 package.json
  4. +5 −1 test/client_server.js
View
@@ -181,6 +181,14 @@ This event has no implicit `ack.accept()` when there are no listeners.
Emitted when the body after the `DATA` command finishes.
+### 'reset'
+
+Emitted when the connection is reset from a `RSET` command.
+
+### 'quit'
+
+Emitted when the connection is closed from a `QUIT` command.
+
properties
----------
View
@@ -47,12 +47,14 @@ module.exports = function (domain, stream) {
}
else if (cmd.name === 'quit') {
write(221, 'Bye!');
+ req.emit('quit');
stream.end();
}
else if (cmd.name === 'rset') {
write(250);
req.to = undefined;
req.from = undefined;
+ req.emit('rset');
next();
}
else if (!req.greeting) {
View
@@ -1,7 +1,7 @@
{
"name" : "smtp-protocol",
"description" : "implements the smtp protocol for clients and servers",
- "version" : "0.1.0",
+ "version" : "0.1.1",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/node-smtp-protocol.git"
View
@@ -6,7 +6,7 @@ var seq = require('seq');
var fs = require('fs');
test('client/server', function (t) {
- t.plan(4);
+ t.plan(5);
var port = Math.floor(Math.random() * 5e4 + 1e4);
var server = smtp.createServer('localhost', function (req) {
@@ -30,6 +30,10 @@ test('client/server', function (t) {
});
ack.accept();
});
+
+ req.on('quit', function () {
+ t.ok(true);
+ });
});
server.listen(port, function () {
var script = '';

0 comments on commit 44d967d

Please sign in to comment.