forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-app.js
More file actions
34 lines (28 loc) · 1.09 KB
/
Copy pathnode-app.js
File metadata and controls
34 lines (28 loc) · 1.09 KB
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
/* ---------------------------------------------------------------------------
Init PubNub and Get your PubNub API Keys:
http://www.pubnub.com/account#api-keys
--------------------------------------------------------------------------- */
console.log('Broadcasting Messages from Node...');
require('child_process').exec('open index.html');
var pubnub = require("./../../pubnub.js").init({
publish_key : "demo",
subscribe_key : "demo"
});
/* ---------------------------------------------------------------------------
Listen for Messages
--------------------------------------------------------------------------- */
pubnub.subscribe({
channel : "my_node_channel",
callback : function(message) {
console.log( "Message From Browser - ", message );
}
});
/* ---------------------------------------------------------------------------
Type Console Message
--------------------------------------------------------------------------- */
setInterval( function() {
pubnub.publish({
channel : "my_browser_channel",
message : 'Hello from Node!'
});
}, 1000 );