diff --git a/src/index.js b/src/index.js index a26a274..2d22db3 100644 --- a/src/index.js +++ b/src/index.js @@ -24,7 +24,10 @@ module.exports = class WebSockets { const url = `ws://${maOpts.host}:${maOpts.port}` log('dialing %s', url) - const socket = connect(url, cb) + const socket = connect(url, { + binary: true, + onConnect: cb + }) socket.getObservedAddrs = (cb) => { return cb(null, [ma]) } diff --git a/test/browser.js b/test/browser.js index 1d63ed0..2e8a918 100644 --- a/test/browser.js +++ b/test/browser.js @@ -40,10 +40,10 @@ describe('libp2p-websockets', () => { const message = rawMessage.toString('hex') const s = goodbye({ - source: pull.values([message]), + source: pull.values([rawMessage]), sink: pull.collect((err, results) => { expect(err).to.not.exist - expect(results).to.be.eql([message]) + expect(results).to.be.eql([rawMessage]) done() }) }) @@ -55,7 +55,7 @@ describe('libp2p-websockets', () => { source: pull( pull.infinite(), pull.take(1000), - pull.map((val) => val.toString()) + pull.map((val) => Buffer(val.toString())) ), sink: pull.collect((err, result) => { expect(err).to.not.exist