blob: 2d06aa890a13fc424d58e8750c609f1265c0a9e5 [file] [log] [blame]
Jeff Thompson287a3182012-11-11 18:12:20 -08001<?xml version = "1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3"DTD/xhtml1-strict.dtd">
Jeff Burke92dd8e42012-12-08 11:40:31 -08004<!--
5 See COPYING for copyright and distribution information.
6-->
Jeff Thompson287a3182012-11-11 18:12:20 -08007<html xmlns = "http://www.w3.org/1999/xhtml">
8
9<head>
10 <title>Test WebSocket Support</title>
11
12 <script type="text/javascript">
13
14 function test(){
15 var output = "";
16
17 if ('WebSocket' in window) {
18 output += "This browser support WebSocket.";
19 } else {
20 output += "No WebSocket support.";
21 }
22
23 document.getElementById('result').innerHTML += output;
24
25 console.log("starting websocket...");
26 if ("WebSocket" in window) {
27 var ws = new WebSocket("ws://localhost:9696");
28
29 ws.onopen = function() {
30 console.log("WebSockets connection opened");
31 ws.send("Hello Server (from client).");
32 }
33 ws.onmessage = function(e) {
34 console.log("Got from server: " + e.data);
35 }
36 ws.onclose = function() {
37 console.log("WebSockets connection closed");
38 }
39 } else {
40 alert("No WebSockets support");
41 }
42
43 }
44
45 </script>
46
47</head>
48<body >
49 <button onclick="test()">Test Now!</button>
50
51 <p id="result">Result here: </p>
52
53</body>
54</html>