Mercurial > libervia-web
diff libervia.py @ 99:ca4fc2b2471b
browser side: signal management
- removed alert in favor of print (except for internal error)
- in case of error, libervia now try to contact the server again to get signals
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 28 Jun 2011 13:53:00 +0200 |
parents | a8f027738c16 |
children | c3fb3292f582 |
line wrap: on
line diff
--- a/libervia.py Tue Jun 28 13:49:08 2011 +0200 +++ b/libervia.py Tue Jun 28 13:53:00 2011 +0200 @@ -60,9 +60,9 @@ dump(o)""" else: if isinstance(errobj['message'],dict): - Window.alert("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString'])) + print("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString'])) else: - Window.alert("Error: %s" % errobj['message']) + print("Error: %s" % errobj['message']) class RegisterCall(LiberviaJsonProxy): def __init__(self): @@ -79,9 +79,15 @@ "tarotGamePlayCards", "getWaitingSub", "subscription", "delContact", "updateContact"]) class BridgeSignals(LiberviaJsonProxy): - def __init__(self): + def __init__(self, host): + self.host = host LiberviaJsonProxy.__init__(self, "/json_signal_api", ["getSignals"]) + + def onRemoteError(self, code, errobj, request_info): + LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info) + #we now try to reconnect + self.host.bridge_signals.call('getSignals', self.host._getSignalsCB) class MicroblogEntry(): def __init__(self, data): @@ -95,7 +101,7 @@ def onModuleLoad(self): self.whoami = None self.bridge = BridgeCall() - self.bridge_signals = BridgeSignals() + self.bridge_signals = BridgeSignals(self) self.selected = None self.uni_box = None self.status_panel = panels.StatusPanel(self) @@ -189,8 +195,7 @@ self._newContactCb(jid, attributes, groups) def _getSignalsCB(self, signal_data): - bridge_signals = BridgeSignals() - bridge_signals.call('getSignals', self._getSignalsCB) + self.bridge_signals.call('getSignals', self._getSignalsCB) print('Got signal ==> name: %s, params: %s' % (signal_data[0],signal_data[1])) name,args = signal_data if name == 'personalEvent':