[sugar] mdns/presence server from python

Dan Williams dcbw
Wed Feb 21 05:48:31 EST 2007


On Tue, 2007-02-20 at 22:06 -0500, Thibaut Lamadon wrote:
> Hi, 
> 
> I'm currently working on a network based activity for the OLPC. Today
> we've met with Chris Blizzard who pointed me to this list.
> 
> I try to use the mdns through python. More generally I'd like to get
> more information and maybe some example (maybe some reference of code
> within sugar to look at ) on how to use the presence server. 

We just spent the past week nailing down the interfaces for the presence
stuff, and that's up on the wiki; search for "Presence Service DBus
API".  Implementation is next up.  The current PresenceService in Sugar
sort of works, but is a prototype.

One consideration here is that you don't just want to use mDNS, you want
to hook in through a Jabber server if you can see one, because you're
not guaranteed to be able to see everyone on the mesh with mDNS.  You're
not even guaranteed to see people 5 feet away from you, because they
could be on a different radio channel, and link-local multicast doesn't
get routed by definition.

The PresenceService will take care of most of this for you.

Dan


> Here is what I've tried, but it doesn't work (it's a stripped down
> version of AvahiBookmark)
> 
> class AvahiTest:
> 
>     def __init__(self, use_host_names):
>         self.bus = dbus.SystemBus() 
>         self.server =
> dbus.Interface(self.bus.get_object(avahi.DBUS_NAME,
> avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
>         self.version_string = self.server.GetVersionString()
>         self.browse_service_type ("_presence_olpc._tcp")
> 
>     def browse_service_type(self, stype):
>         domain="local"
>         browser = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME,
> self.server.ServiceBrowserNew (avahi.IF_UNSPEC, avahi.PROTO_UNSPEC,
> stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER)
>         browser.connect_to_signal('ItemNew', self.new_service)
>         browser.connect_to_signal('ItemRemove', self.remove_service)
> 
>     def new_service(self, interface, protocol, name, type, domain,
> flags):
>         print "new service!!!!"
> 
>     def remove_service(self, interface, protocol, name, type,
> domain): 
>         print "service removed!!!"
> 
> 
> Thks
> 
> Thibaut Lamadon
> 
> 
> _______________________________________________
> Sugar mailing list
> Sugar at laptop.org
> http://mailman.laptop.org/mailman/listinfo/sugar



More information about the Sugar-devel mailing list