-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver_test.html
More file actions
59 lines (49 loc) · 1.63 KB
/
server_test.html
File metadata and controls
59 lines (49 loc) · 1.63 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
<!doctype html>
<html>
<head>
<title>WebSockets Hello World</title>
<meta charset="utf-8" />
<style type="text/css">
body {
text-align: center;
min-width: 500px;
}
</style>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
$(document).ready(function () {
var ws;
$("#open").click(function(evt) {
evt.preventDefault();
var host = $("#host").val();
var port = $("#port").val();
var uri = $("#uri").val();
ws = new WebSocket("ws://" + host + ":" + port + uri);
ws.onmessage = function(evt) {alert("message received: " + evt.data)};
ws.onclose = function(evt) { alert("Connection close"); };
ws.onopen = function(evt) {
$("#host").css("background", "#00ff00");
$("#port").css("background", "#00ff00");
$("#uri").css("background", "#00ff00");
};
});
$("#send").click(function(evt) {
ws.send('ole mano!!');
});
});
</script>
</head>
<body>
<h1>WebSockets Hello World</h1>
<div>
<label for="host">host:</label>
<input type="text" id="host" value="localhost" style="background:#ff0000;"/><br />
<label for="port">port:</label>
<input type="text" id="port" value="8888" style="background:#ff0000;"/><br />
<label for="uri">uri:</label>
<input type="text" id="uri" value="/ws" style="background:#ff0000;"/><br />
<input type="submit" id="open" value="open" />
<input type="button" id="send" value="greet!"/>
</div>
</body>
</html>