Comparing version 0.5.0 to 0.5.1
@@ -87,6 +87,6 @@ var Message = require('./message') | ||
Queue.prototype.onRep = function(event, msg, msgId) { | ||
Queue.prototype.onRep = function(event, args, msgId) { | ||
var inbox = this.reqInbox[msgId] | ||
if (inbox) { | ||
inbox.cb.apply(null, msg) | ||
inbox.cb.apply(null, args) | ||
this.removeReqInbox(msgId) | ||
@@ -123,2 +123,4 @@ } | ||
} | ||
} else if ('string' !== typeof repMsg && !Buffer.isBuffer(repMsg)) { | ||
repMsg = [repMsg] | ||
} | ||
@@ -125,0 +127,0 @@ var buf = encode(REP, event, repMsg, msgId) |
@@ -107,6 +107,6 @@ var Url = require('url') | ||
function getArgs(args, result, start, end, min) { | ||
function getArgs(args, result, start, endOffset, min) { | ||
var len = args.length | ||
if (min < len) { | ||
len -= end | ||
len -= endOffset | ||
var i = start | ||
@@ -117,2 +117,4 @@ result = [result] | ||
} | ||
} else if ('string' !== typeof result && !Buffer.isBuffer(result)) { | ||
result = [result] | ||
} | ||
@@ -119,0 +121,0 @@ return result |
@@ -5,4 +5,8 @@ exports.tcp = require('./net/tcp') | ||
exports.eio = { | ||
bind: require('./engine.io/bind'), | ||
connect: require('./engine.io/connect') | ||
bind: function(target, smq, options, callback) { | ||
return require('./engine.io/bind')(target, smq, options, callback) | ||
}, | ||
connect: function(target, smq, options, callback) { | ||
return require('./engine.io/connect')(target, smq, options, callback) | ||
} | ||
} |
{ | ||
"name": "socketmq", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Lightweight stream-oriented messaging library for node.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -48,2 +48,7 @@ var test = require('tape') | ||
var msg2 = 'msg2' | ||
var obj = { | ||
key: 'value' | ||
} | ||
var arr = ['a', 1, obj] | ||
var num = 6 | ||
var str = 'str' | ||
@@ -53,3 +58,3 @@ var buffer = Buffer('buffer') | ||
test(name + ': pub/sub', function(t) { | ||
t.plan(11) | ||
t.plan(18) | ||
@@ -65,2 +70,18 @@ smqServer.sub('test string', function(str1) { | ||
smqServer.sub('test object', function(obj1) { | ||
t.ok(obj1 && 'object' === typeof obj1, 'get object') | ||
t.equal(obj1.key, obj.key, 'object match') | ||
}) | ||
smqServer.sub('test array', function(arr1) { | ||
t.ok(arr1 && Array.isArray(arr1), 'get array') | ||
t.equal(arr1[0], 'a', 'array[0] match') | ||
t.equal(arr1[1], 1, 'array[1] match') | ||
t.equal(arr1[2].key, obj.key, 'array[2] match') | ||
}) | ||
smqServer.sub('test number', function(num1) { | ||
t.equal(num1, 6, 'number match') | ||
}) | ||
smqServer.sub('test multi arguments', function(arg1, arg2) { | ||
@@ -73,2 +94,5 @@ t.equal(arg1, msg1, 'arg1 match') | ||
smqClient1.pub('test buffer', buffer) | ||
smqClient1.pub('test object', obj) | ||
smqClient1.pub('test array', arr) | ||
smqClient1.pub('test number', num) | ||
smqClient1.pub('test multi arguments', msg1, msg2) | ||
@@ -94,3 +118,3 @@ | ||
test(name + ': req/rep', function(t) { | ||
t.plan(5) | ||
t.plan(7) | ||
@@ -108,2 +132,10 @@ smqClient1.rep('test rep', function(arg1, arg2, reply) { | ||
}) | ||
smqServer.rep('test reply object', function(arg1, reply) { | ||
t.equal(arg1.key, obj.key) | ||
reply(obj) | ||
}) | ||
smqClient1.req('test reply object', obj, function(obj1) { | ||
t.equal(obj1.key, obj.key) | ||
}) | ||
}) | ||
@@ -110,0 +142,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32222
895