Comparing version 0.1.1 to 0.1.2
@@ -7,8 +7,11 @@ var amp = require('amp') | ||
exports.B_PUB = new Buffer(exports.PUB) | ||
exports.B_REQ = new Buffer(exports.REQ) | ||
exports.B_REP = new Buffer(exports.REP) | ||
exports.encode = function(type, event, msg, id) { | ||
var args = [new Buffer(type), new Buffer(event)] | ||
var args = [type, new Buffer(event)] | ||
if (msg) { | ||
msg = Buffer.isBuffer(msg) ? msg : new Buffer(msg) | ||
args.push(msg) | ||
args.push(Buffer.isBuffer(msg) ? msg : new Buffer(msg)) | ||
} | ||
@@ -15,0 +18,0 @@ |
@@ -39,3 +39,3 @@ | ||
// Generate id for callback and save it in inbox. | ||
var id = 'req.inbox.' + this.n | ||
var id = '.' + this.n | ||
this.reqInbox[id] = callback | ||
@@ -42,0 +42,0 @@ // send the buf to selected stream |
@@ -10,2 +10,6 @@ var util = require('util') | ||
var B_PUB = Message.B_PUB | ||
var B_REQ = Message.B_REQ | ||
var B_REP = Message.B_REP | ||
/** | ||
@@ -35,3 +39,3 @@ * Abstract socket class provides our user facing API. | ||
Socket.prototype.pub = function(event, msg) { | ||
var buf = Message.encode(PUB, event, msg) | ||
var buf = Message.encode(B_PUB, event, msg) | ||
this.queue.pub(send, this.streams, buf) | ||
@@ -46,3 +50,3 @@ } | ||
var q = this.queue.req(this.streams, callback) | ||
var buf = Message.encode(REQ, event, msg, q.id) | ||
var buf = Message.encode(B_REQ, event, msg, q.id) | ||
send(q.stream, buf) | ||
@@ -70,3 +74,3 @@ } | ||
var reply = function(msg) { | ||
var buf = Message.encode(REP, event, msg, inboxId) | ||
var buf = Message.encode(B_REP, event, msg, inboxId) | ||
send(stream, buf) | ||
@@ -73,0 +77,0 @@ } |
{ | ||
"name": "socketmq", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Lightweight stream-oriented messaging library for node.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
30987
629
4