* MailPacket class: read() and write() with event emits

* FTNMailPacket WIP derived from MailPacket
This commit is contained in:
Bryan Ashby 2015-07-15 23:51:00 -06:00
parent 7fa27e46a5
commit aebf494ae7
5 changed files with 189 additions and 15 deletions

36
core/mail_packet.js Normal file
View file

@ -0,0 +1,36 @@
/* jslint node: true */
'use strict';
var events = require('events');
var assert = require('assert');
var _ = require('lodash');
module.exports = MailPacket;
function MailPacket(options) {
events.EventEmitter.call(this);
// map of network name -> address obj ( { zone, net, node, point, domain } )
this.nodeAddresses = options.nodeAddresses || {};
}
require('util').inherits(MailPacket, events.EventEmitter);
MailPacket.prototype.read = function(options) {
//
// options.packetPath | opts.packetBuffer: supplies a path-to-file
// or a buffer containing packet data
//
// emits 'message' event per message read
//
assert(_.isString(options.packetPath) || Buffer.isBuffer(options.packetBuffer));
};
MailPacket.prototype.write = function(options) {
//
// options.messages[]: array of message(s) to create packets from
//
// emits 'packet' event per packet constructed
//
assert(_.isArray(options.messages));
}