3
# This server connects to the Event server directly,
4
# it doesn't use the name server but requires a direct URI.
6
from Pyro.EventService.Clients import Publisher
10
symbols = ('SUN','MICROSOFT','IBM','ORACLE','SAP','NOVELL')
12
class StockMarket(Publisher):
13
def __init__(self, symbols, es_URI):
14
Publisher.__init__(self, esURI=es_URI)
16
def publishQuote(self):
17
symbol=random.choice(self.symbols)
18
quote =round(random.random()*100+50,2)
19
print symbol,'=',quote
20
self.publish('STOCKQUOTE.'+symbol, quote)
23
es_URI = raw_input("enter URI of the Event Server: ")
24
market1 = StockMarket(symbols[:3], es_URI)
25
market2 = StockMarket(symbols[3:], es_URI)
27
print 'Publishing quotes.'
29
time.sleep(random.random())
30
market = random.choice( (market1, market2) )
33
if __name__=='__main__':