Skip to content

Instantly share code, notes, and snippets.

@mkozjak
Created September 27, 2016 09:32
Show Gist options
  • Save mkozjak/25fa78521c4dbcdd7d3fccc3d7c7f004 to your computer and use it in GitHub Desktop.
Save mkozjak/25fa78521c4dbcdd7d3fccc3d7c7f004 to your computer and use it in GitHub Desktop.
"use strict"
var C = require("qaap-barge")
var co = require('co')
var c = new C("ws://localhost:8080/rpc/1.0")
c.on("open", function() {
co(function*() {
let r = null
try {
r = yield c.subscribe("foo")
}
catch(error) {
console.log("subs ERROR", error)
}
/*
setTimeout(function() {
co(function*() {
yield c.unsubscribe("foo")
})
}, 3000)
*/
console.log('r meth out:', r)
// c.close()
})
})
c.on("error", function(error) {
console.log("error:", error)
})
c.on("close", function() {
console.log("close")
})
c.on("foo", function(message) {
console.log("###########", message)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment