forked from rlotun/txWebSocket
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
38 lines (34 loc) · 1.24 KB
/
index.html
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
<html>
<head>
<title>Twisted WebSocket Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
<script language='javascript'>
$(document).ready(function() {
var ws;
if (typeof MozWebSocket != "undefined") {
ws = new MozWebSocket("ws://localhost:8080/test");
} else {
ws = new WebSocket("ws://localhost:8080/test");
}
ws.onmessage = function(evt) {
$('#output').text(evt.data);
}
ws.onopen = function(evt) {
$('#conn_status').html('<b>Connected</b>');
ws.send('Test data');
}
ws.onerror = function(evt) {
$('#conn_status').html('<b>Error</b>');
}
ws.onclose = function(evt) {
$('#conn_status').html('<b>Closed</b>');
}
});
</script>
</head>
<body>
<h1>WebSocket in Twisted Test</h1>
<div id="conn_status">Not Connected</div>
<div id="output"></div>
</body>
</html>