forked from ideawu/icomet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforever-iframe.html
More file actions
54 lines (42 loc) · 1.34 KB
/
forever-iframe.html
File metadata and controls
54 lines (42 loc) · 1.34 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>iComet forever-iframe demo</title>
</head>
<body>
<pre style="height:200px; width: 600px; border: 1px solid #999; overflow: auto; background: #eee; padding: 8px;">
## How to Use?
1. start comet-server
2. assuming you are running nginx listening on port 8080, if not,
you will have to modify "8080" in this file to the exact port number,
configure your nginx.conf, add the lines below and restart:
location ~ ^/icomet/.* {
rewrite ^/icomet/(.*) /$1 break;
proxy_buffering off;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_pass http://127.0.0.1:8100;
}
3. navigate your web browser to http://127.0.0.1:8080/web/long-polling.html
or http://127.0.0.1:8080/web/forever-iframe.html
4. open a command line terminal, execute
curl "http://127.0.0.1:8000/pub?cname=a&content=hello"
</pre>
<script>
var count = 0;
function icomet_cb(msg){
if(msg.type != 'data'){
return;
}
count ++;
var output = document.getElementById('output');
var time = '' + (new Date());
output.innerHTML += count + '. ' + time + ': ' + msg.content + '<br/>';
}
</script>
<h3>Server push messages:</h3>
<div id="output"></div>
<iframe src="http://127.0.0.1:8080/icomet/iframe?cname=a" height="0" width="0" border="0" style="border:none;"></iframe>
</body>
</html>