-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.html
39 lines (33 loc) · 1.01 KB
/
default.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
38
39
<html>
<head>
<title>Chat Test</title>
<script src="jquery-1.7.min.js"></script>
<script src="jquery.gracefulWebSocket.js"></script>
<script>
$(function() {
//var ws = new WebSocket("ws://127.0.0.1:8080/");
var ws = $.gracefulWebSocket("ws://127.0.0.1:8080/");
// listen for messages from server using standard syntax
ws.onmessage = function(event) {
$("#messages").append("<p>"+event.data+"</p>");
};
ws.onerror = function(event) {
$("#messages").append("<p>Error: "+event.timeStamp+"</p>");
};
ws.onclose = function(event) {
alert("Socket closed!");
}
$("#send").click(function() { ws.send( $("#msg").val() ); return false; } );
});
</script>
</head>
<body>
<form>
<input type="text" id="name"></input>
<input type="text" id="msg"></input>
<button id="send">Send</button>
</form>
<div id="messages">
</div>
</body>
</html>