forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv4.js
More file actions
56 lines (50 loc) · 1.09 KB
/
v4.js
File metadata and controls
56 lines (50 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var PUBNUB = require("../pubnub.js")
var pubnub = PUBNUB({
publish_key : "demo",
subscribe_key : "demo"
});
var channel = "abcd";
function log(c, m) {
console.log(c + ' : ' + JSON.stringify(m));
}
function connect(m) {log('CONNECT',m)}
function disconnect(m) {log('DISCONNECT',m)}
function reconnect(m) {log('RECONNECT',m)}
function error(m) {log('ERROR',m)}
function callback(m) {log('CALLBACK',m)}
/*
pubnub.subscribe({
channel : 'a',
connect : function(se) {
console.log('CONNECT : ' + JSON.stringify(se,null,2));
},
error : function(e) {
console.log(JSON.stringify(e));
},
callback : function(data) {
console.log(JSON.stringify(data,null,2));
}
});
*/
pubnub.subscribe({
channel_group : 'a',
v2 : false,
status : function(se) {
console.log(JSON.stringify(se,null,2));
},
result : function(data) {
console.log(JSON.stringify(data,null,2));
}
});
/*
pubnub.publish({
channel : channel,
message : 'hi',
status : function(se) {
console.log(JSON.stringify(data, null, 2));
},
result : function(data){
console.log(JSON.stringify(data, null, 2));
}
})
*/