Coder Social home page Coder Social logo

node-dbus's Introduction

DBUS

Node.js bindings for libdbus. There are no dependencies on glib.

var 
	//Get the dbus module
	dbus = require('dbus'), 
	
	//Use the system bus with Avahi namespace
	bus = dbus.system('org.freedesktop.Avahi'), 
	
	//Get the root object and access its server interface
	root = dbus.object('/').as('org.freedesktop.Avahi.Server'); 

//Wait till the root object is ready for operation as the DBus introspection
//system will automatically populate all the methods of the root object
root.on("ready", function() {
	//Call the serviceBrowserNew method as defined by the Avahi specification; all functions have
	//their first letter lowercased and one additional parameter, the callback, added.
	//interface, protocol, type, domain, flags
	root.serviceBrowserNew(-1, -1, "_ssh._tcp", "", 0, function(err, browser) {
		if (err)
			throw new Error('Unable to make service browser: '+err);
		//Now we have a service browser object; all objects are automatically converted into
		//DBUSObject behind the scenes, so we just need to specify the interface of the object
		//we wish to access
		browser = brower.as('org.freedesktop.Avahi.ServiceBrowser');

		//Signals to objects are emitted as events. You do NOT need to wait on the "ready" event
		//to register event handlers. Event names also, likewise, have their first letter lowercased
		//to match JavaScript convention
		browser.on("itemNew", function(interface, protocol, name, type, domain, flags) {
			console.log("Found new service! "+name)
		})
	});
})

node-dbus's People

Contributors

rossburton avatar rektide avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.