3 <title>Test of AFB Echo</title>
4 <script type="text/javascript" src="AFB.js"></script>
5 <script type="text/javascript">
6 var afb = new AFB("api", "hello");
10 document.getElementById("main").style.visibility = "visible";
11 document.getElementById("connected").innerHTML = "Connected to WebSocket server";
12 ws.onevent("*", gotevent);
15 document.getElementById("main").style.visibility = "hidden";
16 document.getElementById("connected").innerHTML = "Connected Closed";
19 ws = new afb.ws(onopen, onabort);
21 function replyok(obj) {
22 document.getElementById("output").innerHTML = "OK: "+JSON.stringify(obj);
24 function replyerr(obj) {
25 document.getElementById("output").innerHTML = "ERROR: "+JSON.stringify(obj);
27 function gotevent(obj) {
28 document.getElementById("outevt").innerHTML = JSON.stringify(obj);
31 var api = document.getElementById("api").value;
32 var verb = document.getElementById("verb").value;
33 var message = document.getElementById("message").value;
35 var data = JSON.parse(message);
36 ws.call(api+"/"+verb, data).then(replyok, replyerr);
38 document.getElementById("output").innerHTML = "INVALID JSON ("+e+"): "+message;
43 <body onload="init();">
44 <h1>WebSocket Echo</h1>
45 <div id="connected">Not Connected</div>
46 <div id="main" style="visibility:hidden">
47 <a href="monitoring/monitor.html" target="_blank">Monitoring</a><br/>
49 API: <input type="text" id="api" value="hello" size="80"/><br/>
50 VERB: <input type="text" id="verb" value="ping" size="80"/><br/>
51 DATA: <input type="text" id="message" value="" size="80" /><br/>
52 <input type="button" value="send" onclick="sendform()"/><br/>
53 Server says... <div id="output"></div>
54 Events: <div id="outevt"></div>