dbus service : removing service do not remove agent(s)
[contrib/cloudeebus.git] / doc / sample / cloudeebus.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 var manifest = {
22         name: "cloudeebus",
23         key: "secret",
24         permissions: [
25                 "org.freedesktop.DBus",
26                 "org.freedesktop.Notifications"
27         ]
28 };
29
30 cloudeebus.log = function(msg) {
31   document.getElementById("log").innerHTML += msg + "\n";
32 }
33
34 function errorCB(error) {
35   cloudeebus.log("error: " + error + "\n");
36 }
37
38 function logCB(result) {
39   cloudeebus.log(JSON.stringify(result));
40 }
41
42 function gotNotifProxy(proxy) {
43   for (var ifproxy in proxy.interfaceProxies)
44     cloudeebus.log(ifproxy);
45   proxy.getInterface("org.freedesktop.Notifications").Notify("Cloudeebus",0,"","Cloudeebus says:", "Hello, world !", [], {}, 0);
46 }
47
48 function gotBusProxy(proxy) {
49   proxy.ListNames().then(logCB, errorCB);
50 }
51
52 function connectSuccess() {
53   cloudeebus.SessionBus().getObject("org.freedesktop.DBus", "/org/freedesktop/DBus", gotBusProxy, errorCB);
54   cloudeebus.SessionBus().getObject("org.freedesktop.Notifications", "/org/freedesktop/Notifications", gotNotifProxy, errorCB);
55 }
56
57 cloudeebus.connect("ws://localhost:9000", manifest, connectSuccess, errorCB);
58 </textarea>
59                 <br>
60                 <input type="button" value="run script" onclick="evalScript()"/>
61                 <input type="button" value="clear log" onclick="document.getElementById('log').innerHTML='';"/>
62                 <br>
63                 <pre id="log" style="height: 20em; overflow-x: auto; overflow-y: auto; background-color: #faa;"></pre>
64    </body>
65 </html>