Repository navigation
Expand file tree
/
Copy pathno-time-check.html
More file actions
64 lines (55 loc) · 1.92 KB
/
Copy pathno-time-check.html
File metadata and controls
64 lines (55 loc) · 1.92 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
57
58
59
60
61
62
63
64
<!doctype html>
<html>
<head>
<!-- Hey, let's be friends! twitter.com/pubnub -->
<title>PubNub JavaScript Multiplexing Test</title>
</head>
<body><div class=container>
<div style="font-family:'Monaco';" id=out>...</div>
<script src=../pubnub.min.js></script>
<script>(function(){
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Testing Examples
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
var pubnub = PUBNUB({
subscribe_key : 'demo',
publish_key : 'demo---111',
keepalive : 1,
timecheck : false
});
PUBNUB.init({
subscribe_key : 'demo',
publish_key : 'demo---222',
keepalive : 3,
timecheck : false
});
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Subscribe
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
subscribe('bot');
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Unsubscribe
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
setTimeout( function() { unsubscribe('bot') }, 30000 );
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Sub/UnSub Helper Functions
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function unsubscribe(channel) { pubnub.unsubscribe({
channel : channel
}) }
function subscribe(channel) { pubnub.subscribe({
channel : channel,
connect : function() { log('NETWORK CONNECTED!!!') },
disconnect : function() { log('NETWORK DISCONNECTED!!!') },
reconnect : function() { log('NETWORK RECONNECTED!!!') },
message : function( message, envelope, channel ) {
log('CHANNEL "' + channel + '": ' + JSON.stringify(message));
}
}) }
function log(data) {
console.log(data);
PUBNUB.$('out').innerHTML += "<div>"+data+"</div>";
}
})();</script>
</div></body>
</html>