changed published service name to name@hostname as in jep-0174
changed contact index to name@hostname
This commit is contained in:
parent
43e44b51dd
commit
e88186d669
|
@ -29,7 +29,6 @@ class Roster:
|
|||
|
||||
'''
|
||||
delItem(jid)
|
||||
getItem(jid)
|
||||
getStatus(jid)
|
||||
getPriority(jid)
|
||||
getShow(jid)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import sys
|
||||
import getpass
|
||||
import socket
|
||||
|
||||
try:
|
||||
import avahi, gobject, dbus
|
||||
|
@ -17,7 +18,9 @@ class Zeroconf:
|
|||
self.domain = None # specific domain to browse
|
||||
self.stype = '_presence._tcp'
|
||||
self.port = 5298 # listening port that gets announced
|
||||
self.name = getpass.getuser() # service name / username
|
||||
|
||||
self.name = getpass.getuser()+'@'+socket.gethostname() # service name / username
|
||||
|
||||
self.txt = {} # service data
|
||||
|
||||
self.service_browsers = {}
|
||||
|
@ -40,7 +43,7 @@ class Zeroconf:
|
|||
|
||||
def remove_service_callback(self, interface, protocol, name, stype, domain, flags):
|
||||
print "Service '%s' in domain '%s' on %i.%i disappeared." % (name, domain, interface, protocol)
|
||||
del self.contacts[(name, stype, domain, interface)]
|
||||
del self.contacts[name]
|
||||
|
||||
def new_service_type(self, interface, protocol, stype, domain, flags):
|
||||
# Are we already browsing this domain for this type?
|
||||
|
@ -74,14 +77,17 @@ class Zeroconf:
|
|||
print "Service data for service '%s' in domain '%s' on %i.%i:" % (name, domain, interface, protocol)
|
||||
print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(avahi.txt_array_to_string_array(txt)))
|
||||
|
||||
'''
|
||||
# add domain to stay unique
|
||||
if domain != 'local':
|
||||
add_domain = '%'+domain
|
||||
add_domain = '.'+domain
|
||||
else:
|
||||
add_domain = ''
|
||||
|
||||
self.contacts[name+add_domain+'@'+host] = (name, stype, domain, interface, protocol, host, address, port, txt)
|
||||
self.contacts[name'@'+host+add_domain] = (name, stype, domain, interface, protocol, host, address, port, txt)
|
||||
'''
|
||||
|
||||
self.contacts[name] = (name, stype, domain, interface, protocol, host, address, port, txt)
|
||||
|
||||
def service_added_callback(self):
|
||||
print 'Service successfully added'
|
||||
|
@ -181,7 +187,6 @@ class Zeroconf:
|
|||
self.remove_announce()
|
||||
|
||||
|
||||
|
||||
# refresh data manually - really ok or too much traffic?
|
||||
def resolve_all(self):
|
||||
for val in self.contacts.values():
|
||||
|
@ -194,7 +199,6 @@ class Zeroconf:
|
|||
self.resolve_all()
|
||||
return self.contacts
|
||||
|
||||
|
||||
def update_txt(self, txt):
|
||||
# update only given keys
|
||||
for key in txt.keys():
|
||||
|
@ -215,8 +219,9 @@ class Zeroconf:
|
|||
|
||||
zeroconf = Zeroconf()
|
||||
zeroconf.connect()
|
||||
zeroconf.txt[('1st')] = 'foo'
|
||||
zeroconf.txt[('last')] = 'bar'
|
||||
zeroconf.txt['1st'] = 'foo'
|
||||
zeroconf.txt['last'] = 'bar'
|
||||
zeroconfptxt['email'] = foo@bar.org
|
||||
zeroconf.announce()
|
||||
|
||||
# updating after announcing
|
||||
|
|
Loading…
Reference in New Issue