Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
improve binary data sending
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Aug 30, 2016
1 parent 4d4fa5a commit d6c6aea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
6 changes: 3 additions & 3 deletions test/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
Expand All @@ -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
Expand Down

0 comments on commit d6c6aea

Please sign in to comment.