My first Javascript app
Last night I tried to make a small app/script in javascript (gjs) and it actually worked. :) Here is the code:
const GLib = imports.gi.GLib;
const GUPnP = imports.gi.GUPnP;
const Mainloop = imports.mainloop;
// This doesn't start any threads
GLib.thread_init (null);
let context = new GUPnP.Context ({ main_context: null,
host_ip: null,
port: 0
});
let cp = new GUPnP.ControlPoint ({ client: context,
target: "ssdp:all"
});
function onDeviceProxyAvailable (cp, proxy) {
log (proxy.get_friendly_name ());
}
// Tell us when there is a new device available
cp.connect ("device-proxy-available", onDeviceProxyAvailable);
// Search and listen for UPnP resources on the network
cp.set_active (true);
Mainloop.run ("0");
Comments
Mixed feelings, but glad the gtk+ effort is starting :)
> revolutionary. Then I
> realized that Adobe AIR
> already dos html+js for
> the desktop.
I hope you mean the ability to use js for gobject libraries rather than my app. :) The latter is hardly any revolutionary. :)
The former is revolutionary in the sense that it brings all the nice gobject-based libraries to thousands of javascript developers out there. Admitted that it won't be much of a revolution if it wasn't based on gobject-introspection and hence not so powerful.