1
edit
Changes
Proxy
,no edit summary
===Code Samples===
import Pyro.core, Pyro.naming, Pyro.constants import Pyro.EventService.Server from Pyro.errors import *
# SUBSCRIBER: subscribes to certain events. class Subscriber(Pyro.core.CallbackObjBase): def __init__(self, ident=None): Pyro.core.ObjBase.__init__(self) Pyro.core.initServer() Pyro.core.initClient() daemon = Pyro.core.Daemon() locator = Pyro.naming.NameServerLocator(identification=ident) self.NS = locator.getNS(host=Pyro.config.PYRO_NS_HOSTNAME) daemon.useNameServer(self.NS) daemon.connect(self) # will also set self.daemon... uri = self.NS.resolve(Pyro.constants.EVENTSERVER_NAME) self.eventservice=Pyro.core.getProxyForURI(uri) self.eventservice._setIdentification(ident) self.abortListen=0 self.daemon=daemon # make sure daemon doesn't get garbage collected now
# PUBLISHER: publishes events. class Publisher: def __init__(self, ident=None): Pyro.core.initClient() locator = Pyro.naming.NameServerLocator(identification=ident) ns = locator.getNS(host=Pyro.config.PYRO_NS_HOSTNAME) uri = ns.resolve(Pyro.constants.EVENTSERVER_NAME) self.eventservice=Pyro.core.getProxyForURI(uri) self.eventservice._setIdentification(ident)