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");