Skip to content

Commit ecce6ac

Browse files
committed
making it work
1 parent 0dbe650 commit ecce6ac

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ server.listen(port, function () {
4848
})
4949

5050
// Attach WS to solid
51-
solidWs(server)
51+
solidWs(server, app)
5252
```

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
var SolidWs = require('./server')
1+
var SolidWs = require('./lib/server')
22

33
module.exports = function attachToServer (server, app, opts) {
44
var solidWs = new SolidWs(server, opts)
5-
if (app) server.on('request', app)
65
return solidWs
76
}

lib/in-memory.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ InMemory.prototype.subscribe = function (uri, client, callback) {
2727
}
2828

2929
InMemory.prototype.get = function (uri, callback) {
30-
return callback(null, this.subscribers)
30+
console.log(this.subscribers, uri)
31+
return callback(null, this.subscribers[uri])
3132
}

lib/server.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ function WsServer (server, opts) {
5858

5959
WsServer.prototype.publish = function (uri, callback) {
6060
this.store.get(uri, function (err, subscribers) {
61-
if (err) return callback(err)
61+
62+
if (err) {
63+
if (callback) return callback(err)
64+
else return
65+
}
6266

6367
var tasks = Object.keys(subscribers)
6468
.map(function (uuid) {
6569
return function (cb) {
66-
var client = subscribers[uri][uuid]
70+
var client = subscribers[uuid]
6771
client.send('pub ' + uri)
6872
}
6973
})

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@
1515
"web"
1616
],
1717
"author": "Nicola Greco <me@nicola.io> (http://nicola.io/)",
18-
"license": "MIT"
18+
"license": "MIT",
19+
"dependencies": {
20+
"debug": "^2.2.0",
21+
"node-uuid": "^1.4.3",
22+
"run-parallel": "^1.1.4"
23+
}
1924
}

0 commit comments

Comments
 (0)