Comparing version 0.5.8 to 0.5.9
var wire = require('./wire') | ||
var type = require('./type') | ||
var Buffer = type.Buffer | ||
var isBuffer = Buffer.isBuffer | ||
@@ -5,0 +5,0 @@ |
@@ -0,1 +1,2 @@ | ||
var Buffer = require('./type').Buffer | ||
var jsonEncode = JSON.stringify | ||
@@ -2,0 +3,0 @@ var jsonDecode = JSON.parse |
@@ -0,2 +1,6 @@ | ||
if ('undefined' === typeof Buffer) { | ||
Buffer = require('buffer').Buffer | ||
} | ||
exports.Buffer = Buffer | ||
@@ -3,0 +7,0 @@ exports.PUB = 'PUB' |
var amp = require('amp') | ||
var TYPES = require('./type').TYPES | ||
var type = require('./type') | ||
var TYPES = type.TYPES | ||
var Buffer = type.Buffer | ||
exports.encode = function(pack) { | ||
@@ -6,0 +7,0 @@ var args = [TYPES[pack.type], Buffer(pack.event), pack.formatId, pack.msg] |
var type = require('../message/type') | ||
var wire = require('../message/wire') | ||
var Queue = require('./index') | ||
var Buffer = type.Buffer | ||
var inherits = require('inherits') | ||
@@ -5,0 +6,0 @@ |
var type = require('../message/type') | ||
var pubsub = require('./pubsub') | ||
var reqrep = require('./reqrep') | ||
var Buffer = type.Buffer | ||
@@ -5,0 +6,0 @@ |
var Url = require('url') | ||
var json = require('../message/json') | ||
var Queue = require('../queue') | ||
var Message = require('../message') | ||
var Queue = require('../queue/index') | ||
var Buffer = require('../message/type').Buffer | ||
var Message = require('../message/index') | ||
var inherits = require('inherits') | ||
var transport = require('../transport') | ||
var transport = require('../transport/index') | ||
var StreamParser = require('../message/wire').StreamParser | ||
@@ -8,0 +9,0 @@ |
var Duplex = require('stream').Duplex | ||
var Buffer = require('../../message/type').Buffer | ||
@@ -74,2 +75,5 @@ exports.getDefaultOptions = function(options) { | ||
socket.on('message', function(buf) { | ||
// Might be an ArrayBuffer in browser | ||
if (buf && !Buffer.isBuffer(buf) && 'undefined' !== typeof buf.byteLength) | ||
buf = new Buffer(buf) | ||
stream.push(buf) | ||
@@ -86,3 +90,7 @@ }) | ||
socket.on('error', function(err) { | ||
stream.emit('error', err) | ||
}) | ||
return stream | ||
} |
var eio = require('engine.io-client') | ||
var url = require('url') | ||
var common = require('./common') | ||
@@ -9,7 +10,4 @@ var createStream = common.createStream | ||
module.exports = function connect(target, smq, options, callback) { | ||
var uri = 'ws://' + target.hostname | ||
if (target.port) | ||
uri = uri + ':' + target.port | ||
options = getDefaultOptions(options) | ||
var uri = getConnectionUri(target, options.https) | ||
@@ -26,1 +24,22 @@ var socket = eio(uri, options) | ||
} | ||
function getConnectionUri(target, https) { | ||
target.protocol = 'ws:' | ||
if ((!target.hostname || !target.port) && 'undefined' !== typeof window) { | ||
var browserTarget = url.parse(window.location.href) | ||
if (browserTarget.protocol) { | ||
target.protocol = 'https:' === browserTarget.protocol ? 'wss:' : 'ws:' | ||
target.hostname = target.hostname || browserTarget.hostname | ||
target.port = target.port || browserTarget.port | ||
} | ||
} | ||
if (true === https) | ||
target.protocol = 'wss:' | ||
var uri = target.protocol + '//' + target.hostname | ||
if (target.port) | ||
uri = uri + ':' + target.port | ||
return uri | ||
} |
{ | ||
"name": "socketmq", | ||
"version": "0.5.8", | ||
"version": "0.5.9", | ||
"description": "Lightweight stream-oriented messaging library for node.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
43033
1239