Mercurial > libervia-web
diff libervia.tac @ 36:1d406077b49b
Tarot Game: first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 17 May 2011 01:33:12 +0200 |
parents | d43d6e4b9dc8 |
children | b306aa090438 |
line wrap: on
line diff
--- a/libervia.tac Mon May 16 18:19:35 2011 +0200 +++ b/libervia.tac Tue May 17 01:33:12 2011 +0200 @@ -33,10 +33,13 @@ from txjsonrpc import jsonrpclib from sat_frontends.bridge.DBus import DBusBridgeFrontend,BridgeExceptionNoService import re +import glob +import os.path from server_side.blog import MicroBlog TIMEOUT = 120 #Session's time out, after that the user will be disconnected - +LIBERVIA_DIR = "output/" +CARDS_DIR = "cards/" class MethodHandler(jsonrpc.JSONRPC): @@ -121,6 +124,12 @@ profile = self.session.sat_profile self.sat_host.bridge.tarotGameLaunch(other_players, profile) + def jsonrpc_getTarotCardsPaths(self): + """Give the path of all the tarot cards""" + return map(lambda x: x[len(LIBERVIA_DIR):],glob.glob(os.path.join(LIBERVIA_DIR,CARDS_DIR,'*_*.png'))); + + + class Register(jsonrpc.JSONRPC): """This class manage the registration procedure with SàT It provide an api for the browser, check password and setup the web server""" @@ -329,7 +338,7 @@ class Libervia(service.Service): def __init__(self): - root = File("output/") + root = File(LIBERVIA_DIR) self.signal_handler = SignalHandler(self) _register = Register(self) self.signal_handler.plugRegister(_register) @@ -344,7 +353,7 @@ sys.exit(1) self.bridge.register("connected", self.signal_handler.connected) self.bridge.register("connectionError", self.signal_handler.connectionError) - for signal_name in ['presenceUpdate', 'personalEvent', 'newMessage', 'roomJoined', 'roomUserJoined', 'roomUserLeft']: + for signal_name in ['presenceUpdate', 'personalEvent', 'newMessage', 'roomJoined', 'roomUserJoined', 'roomUserLeft', 'tarotGameStarted']: self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) root.putChild('json_signal_api', self.signal_handler) root.putChild('json_api', MethodHandler(self))