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);
30 function send(message) {
31 var api = document.getElementById("api").value;
32 var verb = document.getElementById("verb").value;
33 ws.call(api+"/"+verb, {data:message}).then(replyok, replyerr);
37 <body onload="init();">
38 <h1>WebSocket Echo</h1>
39 <div id="connected">Not Connected</div>
40 <div id="main" style="visibility:hidden">
41 API: <input type="text" id="api" value="hello" size="80"/><br/>
42 VERB: <input type="text" id="verb" value="ping" size="80"/><br/>
43 Enter Message: <input type="text" name="message" value="" size="80" onchange="send(this.value)"/><br/>
44 Server says... <div id="output"></div>
45 Events: <div id="outevt"></div>