comparison libervia.tac @ 117:2e2e10785c33

server side: refactored signal according to SàT's bridge changes + getCardCache handling + updatedValue handling
author Goffi <goffi@goffi.org>
date Wed, 06 Jul 2011 01:09:19 +0200
parents dfc02690deb4
children 2d40b0f5fb37
comparison
equal deleted inserted replaced
116:aff34642616b 117:2e2e10785c33
261 def jsonrpc_tarotGamePlayCards(self, player_nick, referee, cards): 261 def jsonrpc_tarotGamePlayCards(self, player_nick, referee, cards):
262 """Tell to the server that we are ready to start the game""" 262 """Tell to the server that we are ready to start the game"""
263 profile = ISATSession(self.session).profile 263 profile = ISATSession(self.session).profile
264 self.sat_host.bridge.tarotGamePlayCards(player_nick, referee, cards, profile) 264 self.sat_host.bridge.tarotGamePlayCards(player_nick, referee, cards, profile)
265 265
266 def jsonrpc_getAvatar(self, jid): 266 def jsonrpc_getCardCache(self, jid):
267 """Get the avatar of a contact 267 """Get the avatar of a contact
268 @param jid: jid of contact from who we want the avatar 268 @param jid: jid of contact from who we want the avatar
269 @return: path to the avatar image""" 269 @return: path to the avatar image"""
270 cache = self.bridge.getCardCache(jid) 270 return self.sat_host.bridge.getCardCache(jid)
271 if cache.has_key('avatar'):
272 return self.bridge.getAvatarFile(cache['avatar'])
273 271
274 class Register(jsonrpc.JSONRPC): 272 class Register(jsonrpc.JSONRPC):
275 """This class manage the registration procedure with SàT 273 """This class manage the registration procedure with SàT
276 It provide an api for the browser, check password and setup the web server""" 274 It provide an api for the browser, check password and setup the web server"""
277 275
607 except BridgeExceptionNoService: 605 except BridgeExceptionNoService:
608 print(u"Can't connect to SàT backend, are you sure it's launched ?") 606 print(u"Can't connect to SàT backend, are you sure it's launched ?")
609 sys.exit(1) 607 sys.exit(1)
610 self.bridge.register("connected", self.signal_handler.connected) 608 self.bridge.register("connected", self.signal_handler.connected)
611 self.bridge.register("connectionError", self.signal_handler.connectionError) 609 self.bridge.register("connectionError", self.signal_handler.connectionError)
612 self.bridge.register("actionResult", self.action_handler.actionResultCb, "request") 610 self.bridge.register("actionResult", self.action_handler.actionResultCb)
613 for signal_name in ['presenceUpdate', 'personalEvent', 'newMessage', 'roomJoined', 'roomUserJoined', 'roomUserLeft', 'tarotGameStarted', 'tarotGameNew', 611 #core
614 'tarotGameChooseContrat', 'tarotGameShowCards', 'tarotGameInvalidCards', 'tarotGameCardsPlayed', 'tarotGameYourTurn', 'tarotGameScore', 612 for signal_name in ['presenceUpdate', 'newMessage', 'subscribe', 'contactDeleted', 'newContact', 'updatedValue']:
615 'subscribe', 'contactDeleted', 'newContact']:
616 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) 613 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name))
614 #plugins
615 for signal_name in ['personalEvent', 'roomJoined', 'roomUserJoined', 'roomUserLeft', 'tarotGameStarted', 'tarotGameNew', 'tarotGameChooseContrat',
616 'tarotGameShowCards', 'tarotGameInvalidCards', 'tarotGameCardsPlayed', 'tarotGameYourTurn', 'tarotGameScore']:
617 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name), "plugin")
617 self.media_dir = self.bridge.getConfig('','media_dir') 618 self.media_dir = self.bridge.getConfig('','media_dir')
618 self.local_dir = self.bridge.getConfig('','local_dir') 619 self.local_dir = self.bridge.getConfig('','local_dir')
619 root.putChild('json_signal_api', self.signal_handler) 620 root.putChild('json_signal_api', self.signal_handler)
620 root.putChild('json_api', MethodHandler(self)) 621 root.putChild('json_api', MethodHandler(self))
621 root.putChild('register_api', _register) 622 root.putChild('register_api', _register)