rocket.chat.mqtt
Version:
It's a MQTT Server, using redis to scale horizontally.
27 lines (19 loc) • 580 B
JavaScript
// encoder.js
exports.Encoder = Encoder;
var EventLite = require("event-lite");
var EncodeBuffer = require("./encode-buffer").EncodeBuffer;
function Encoder(options) {
if (!(this instanceof Encoder)) return new Encoder(options);
EncodeBuffer.call(this, options);
}
Encoder.prototype = new EncodeBuffer();
EventLite.mixin(Encoder.prototype);
Encoder.prototype.encode = function(chunk) {
this.write(chunk);
this.emit("data", this.read());
};
Encoder.prototype.end = function(chunk) {
if (arguments.length) this.encode(chunk);
this.flush();
this.emit("end");
};