-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.html
More file actions
36 lines (31 loc) · 1.03 KB
/
index.html
File metadata and controls
36 lines (31 loc) · 1.03 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
<DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>C# WebSocket Test</title>
</head>
<body>
<script type="text/javascript">
var socket = new WebSocket("ws://127.0.0.1:80");
socket.onopen = function(e) {
alert('Connected to server!');
}
socket.onclose = function(e) {
alert('Disconnected from server');
}
socket.onmessage = function(e) {
alert('Message from server:\n'+e.data);
}
socket.onerror = function(e) {
alert('An error has occured!\n'+e.message);
}
function SendToServer() {
var text = document.getElementById('tb-send').value;
socket.send(text);
}
</script>
<h1 style="width:100%;float:left;">C# WebSocket Server Example</h1>
<input id="tb-send" type="text" value="" />
<button onclick="SendToServer()">Send!</button>
</body>
</html>