forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.js
More file actions
31 lines (24 loc) · 869 Bytes
/
hello.js
File metadata and controls
31 lines (24 loc) · 869 Bytes
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
/* ---------------------------------------------------------------------------
Init PubNub and Get your PubNub API Keys:
http://www.pubnub.com/account#api-keys
--------------------------------------------------------------------------- */
var PUBNUB = require("../pubnub.js")
var pubnub = PUBNUB({
publish_key : "demo",
subscribe_key : "demo"
//cipher_key : "demo"
});
console.log(pubnub.get_version());
/* ---------------------------------------------------------------------------
Listen for Messages
--------------------------------------------------------------------------- */
pubnub.subscribe({
channel : "a",
callback : function(message) {
console.log( " > ", message );
},
error : function(r) {
console.log(JSON.stringify(r));
},
presence : function(r) { console.log(JSON.stringify(r)) }
});