Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from learn-co/events
Browse files Browse the repository at this point in the history
Emit open & close events
  • Loading branch information
drewprice authored Apr 28, 2017
2 parents d51cf5d + 58b7fe7 commit e7dabea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ bus.on('create', ({key, url}) => {
bus.emit(`${key}:open:cached`)
} else {
cache.createWebSocket(key, url, {
onopen() {
onopen(e) {
console.log(`websocket open for ${this.key}: ${this.url}`)
bus.emit(`${this.key}:open`)
bus.emit(`${this.key}:open`, e)
},

onmessage(msg) {
Expand All @@ -44,9 +44,9 @@ bus.on('create', ({key, url}) => {
bus.emit(`${this.key}:error`, err)
},

onclose() {
onclose(e) {
console.log(`websocket close for ${this.key}: ${this.url}`)
bus.emit(`${this.key}:close`)
bus.emit(`${this.key}:close`, e)
}
})

Expand Down

0 comments on commit e7dabea

Please sign in to comment.