forked from inaes-tic/mbc-caspa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mubsub.test.js
43 lines (36 loc) · 1.11 KB
/
mubsub.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var db = require('mongoskin').db('localhost:27017/mediadb?auto_reconnect', {safe:true});
var mubsub = require ('mubsub');
var client = mubsub (db);
var channel = client.channel('messages');
var App = require ('./models/App');
var Media = require ('./models/Media');
var Status = new App.Status ();
function publish_model (channel, model) {
channel.publish ({method: 'update', backend: model.backend, model: model.toJSON()});
}
channel.subscribe ({}, function (sched) {
console.log ("got message:", sched);
});
Status.set ({
piece: {
previous: "014c761138a57e0b35694e37a44358ae",
current: "0bbe5a274cef3008ef05354134224cf5",
next: "73b9eb63aa2c3b9ecb7ce37f2cbdaf58",
},
show: {
previous: "prevous show",
current: "current show",
next: "next show",
},
source: "this source",
on_air: true,
});
publish_model (channel, Status);
/*
setTimeout (function () {
AppModel.state++;
console.log ('state now:', AppModel.state);
publish_model (channel, AppModel);
}, 10000);
*/
console.log ("listening on 'messages'");