forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.html
More file actions
40 lines (36 loc) · 1.17 KB
/
simple.html
File metadata and controls
40 lines (36 loc) · 1.17 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
<div id=pubnub></div>
<script src="../pubnub.js"></script>
<script>(function(){
// INIT PubNub
var pubnub = PUBNUB.init({
publish_key : 'demo',
subscribe_key : 'demo',
ssl : true,
jsonp : false
});
// LISTEN
pubnub.subscribe({
channel : "my_channel,your_channel,our_channel",
message : function(m){ console.log(JSON.stringify(m)) },
connect : function(channel) {
console.log('CONNECT on ' + channel);
// SEND
pubnub.publish({
channel : channel,
message : "Hi." ,
callback : function(r){
console.log(JSON.stringify(r));
pubnub.unsubscribe({
channel : "my_channel,our_channel",
callback : function(r) {
console.log("UNSUB CALLBACK " + JSON.stringify(r));
},
error : function(e) {
console.log('UNSUB ERROR ' + JSON.stringify(e));
}
});
}
});
}
});
})();</script>