Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@
)

// Event binding examples
client.bind('connected', function() {
client.on('connected', function() {
log('A connection has been established!')
})

subscription.bind('subscribed', function() {
subscription.on('subscribed', function() {
log('Subscribed to '+subscription.streamId)
})

subscription.bind('resending', function() {
subscription.on('resending', function() {
log('Resending from '+subscription.streamId)
})

subscription.bind('resent', function() {
subscription.on('resent', function() {
log('Resend complete for '+subscription.streamId)
})

subscription.bind('no_resend', function() {
subscription.on('no_resend', function() {
log('Nothing to resend for '+subscription.streamId)
})
</script>
Expand Down
10 changes: 5 additions & 5 deletions examples/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ var subscription = client.subscribe(
)

// Event binding examples
client.bind('connected', function() {
client.on('connected', function() {
console.log('A connection has been established!')
})

subscription.bind('subscribed', function() {
subscription.on('subscribed', function() {
console.log('Subscribed to '+subscription.streamId)
})

subscription.bind('resending', function() {
subscription.on('resending', function() {
console.log('Resending from '+subscription.streamId)
})

subscription.bind('resent', function() {
subscription.on('resent', function() {
console.log('Resend complete for '+subscription.streamId)
})

subscription.bind('no_resend', function() {
subscription.on('no_resend', function() {
console.log('Nothing to resend for '+subscription.streamId)
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"license": "",
"dependencies": {
"debug": "*",
"eventemitter3": "*"
"eventemitter3": "*",
"ws": "^3.0.0"
},
"devDependencies": {
"mocha": "*",
Expand Down
12 changes: 9 additions & 3 deletions streamr-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
(function() {

var debug
if (typeof window !== 'undefined') {
if (typeof module !== 'undefined') {
debug = require('debug')('StreamrClient')
} else {
debug = (window.debug ? window.debug('StreamrClient') : function() {
if (window.consoleLoggingEnabled)
console.log.apply(console, arguments)
})
}
else {
debug = require('debug')('StreamrClient')

var WebSocket
if (typeof module !== 'undefined') {
WebSocket = require('ws')
} else {
WebSocket = window.WebSocket
}

var BYE_KEY = "_bye"
Expand Down
1 change: 0 additions & 1 deletion test/test.streamr-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ describe('StreamrClient', function() {
return socket
});

global.WebSocket = require('ws')
StreamrClient = require('../streamr-client')
})

Expand Down