Python 7.0pl5 Instrukcja Użytkownika Strona 43

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 124
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 42
Service Announcements
43
Service Announcements
If a service agent subscribes to the registry using a specific service name, the service agent will be no-
tified when any service with that name becomes available or is subsequently withdrawn. When sub-
scribing to the registry using a specific service name, no notification is given regarding groups that
those same services may join.
class ServiceMonitor(netsvc.Monitor):
def __init__(self,name):
netsvc.Monitor.__init__(self)
self.subscribeServiceName(self.announce,name)
def announce(self,binding,status):
action = "WITHDRAWN"
if status == netsvc.SERVICE_AVAILABLE:
action = "AVAILABLE"
name = binding.serviceName()
identity = binding.agentIdentity()
print "SERVICE-%s: %s (%s)" % (action,`name`,identity)
The name of the member function for subscribing to the existance of a service agent by name is "sub-
scribeServiceName()". A subscription can be cancelled by calling the member function "un-
subscribeServiceName()".
Having identified a particular service agent, it is often useful to know when that specific service agent
is no longer available. The notifications provided when you call the member function "subscribe-
ServiceName()" will tell you that, but if the service binding had been received through some other
means and you weren’t receiving the notifications, it is preferable that you be able to receive a notifi-
cation just in relation to the specific service agent you are using. In this case, the service address can
be obtained from the service binding by calling "serviceAddress()" and the member function
"subscribeServiceAddress()" used instead. This subscription can be cancelled by calling the
"unsubscribeServiceAddress()" member function.
class ClientService(netsvc.Service):
def __init__(self,binding):
netsvc.Service.__init__(self)
address = binding.serviceAddress()
self.subscribeServiceAddress(self.announce,address)
self._binding = binding
# start using service
def self.announce(self,binding,group,status):
if group == None:
if binding.agentIdentity() == self._binding.agentIdentity():
if status == netsvc.SERVICE_WITHDRAWN:
self.unsubscribeServiceAddress(binding.serviceAddress())
self._binding = None
# stop using service
Przeglądanie stron 42
1 2 ... 38 39 40 41 42 43 44 45 46 47 48 ... 123 124

Komentarze do niniejszej Instrukcji

Brak uwag

Perixx PERITUNE-401 manuals

Owner’s manuals and user’s guides for The input devices Perixx PERITUNE-401.
We providing 1 pdf manuals Perixx PERITUNE-401 for download free by document types: User Manual


Perixx PERITUNE-401 User Manual (1 pages)


Brand: Perixx | Category: The input devices | Size: 1.27 MB |

 

Table of contents





More products and manuals for The input devices Perixx

Models Document Type
PERITAB-301 User Manual       Perixx PERITAB-301 User Manual, 61 pages
PERITAB-302 User Manual   Perixx PERITAB-302 User Manual, 1 pages
PX-5000 User Manual   Perixx PX-5000 User Manual, 1 pages
PERIPRO-402 User Manual   Perixx PERIPRO-402 User Manual, 1 pages
PERIPRO-707 User Manual   Perixx PERIPRO-707 User Manual, 1 pages
PERIPAD-501 User Manual   Perixx PERIPAD-501 User Manual, 1 pages