agent client/server doc: service creation
[contrib/cloudeebus.git] / doc / agent / server.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <script src="../../lib/autobahn.min.js"></script>
5         <script src="../../cloudeebus/cloudeebus.js"></script>
6         <script type="text/javascript">
7                 function evalScript() {
8                         eval(
9                                 "var lambda = function() {" +
10                                         document.getElementById('script').value +
11                                 "};" + 
12                                 "lambda();"
13                         );
14                 }
15         </script>
16     </head>
17    <body>
18         <center><h1>cloudeebus</h1></center>
19         <br>
20                 <textarea style="width:80%" rows="32" id="script">
21 cloudeebus.log = function(msg) {
22   document.getElementById("log").innerHTML += msg + "\n";
23 }
24
25 function logCB(result) {
26   cloudeebus.log(JSON.stringify(result));
27 }
28
29 function errorCB(error) {
30   cloudeebus.log(error.desc ? error.desc : error);
31 }
32
33 function connectSuccess() {
34   cloudeebus.SessionBus().addService("org.cloudeebus.Sample", logCB, errorCB);
35 }
36
37 cloudeebus.connect("ws://localhost:9003", null, connectSuccess, errorCB);
38 </textarea>
39                 <br>
40                 <input type="button" value="run script" onclick="evalScript()"/>
41                 <input type="button" value="clear log" onclick="document.getElementById('log').innerHTML='';"/>
42                 <br>
43                 <pre id="log" style="height: 20em; overflow-x: auto; overflow-y: auto; background-color: #faa;"></pre>
44    </body>
45 </html>