Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
98:bd0ca532fdf9 | 99:ca4fc2b2471b |
---|---|
58 Window.alert("Internal server error") | 58 Window.alert("Internal server error") |
59 """for o in code, error, request_info: | 59 """for o in code, error, request_info: |
60 dump(o)""" | 60 dump(o)""" |
61 else: | 61 else: |
62 if isinstance(errobj['message'],dict): | 62 if isinstance(errobj['message'],dict): |
63 Window.alert("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString'])) | 63 print("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString'])) |
64 else: | 64 else: |
65 Window.alert("Error: %s" % errobj['message']) | 65 print("Error: %s" % errobj['message']) |
66 | 66 |
67 class RegisterCall(LiberviaJsonProxy): | 67 class RegisterCall(LiberviaJsonProxy): |
68 def __init__(self): | 68 def __init__(self): |
69 LiberviaJsonProxy.__init__(self, "/register_api", | 69 LiberviaJsonProxy.__init__(self, "/register_api", |
70 ["isRegistered","isConnected","connect"]) | 70 ["isRegistered","isConnected","connect"]) |
77 ["getContacts", "addContact", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", "getPresenceStatus", | 77 ["getContacts", "addContact", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", "getPresenceStatus", |
78 "joinMUC", "getRoomJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", | 78 "joinMUC", "getRoomJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", |
79 "tarotGamePlayCards", "getWaitingSub", "subscription", "delContact", "updateContact"]) | 79 "tarotGamePlayCards", "getWaitingSub", "subscription", "delContact", "updateContact"]) |
80 | 80 |
81 class BridgeSignals(LiberviaJsonProxy): | 81 class BridgeSignals(LiberviaJsonProxy): |
82 def __init__(self): | 82 def __init__(self, host): |
83 self.host = host | |
83 LiberviaJsonProxy.__init__(self, "/json_signal_api", | 84 LiberviaJsonProxy.__init__(self, "/json_signal_api", |
84 ["getSignals"]) | 85 ["getSignals"]) |
86 | |
87 def onRemoteError(self, code, errobj, request_info): | |
88 LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info) | |
89 #we now try to reconnect | |
90 self.host.bridge_signals.call('getSignals', self.host._getSignalsCB) | |
85 | 91 |
86 class MicroblogEntry(): | 92 class MicroblogEntry(): |
87 def __init__(self, data): | 93 def __init__(self, data): |
88 self.id = data['id'] | 94 self.id = data['id'] |
89 self.content = data['content'] | 95 self.content = data['content'] |
93 | 99 |
94 class SatWebFrontend: | 100 class SatWebFrontend: |
95 def onModuleLoad(self): | 101 def onModuleLoad(self): |
96 self.whoami = None | 102 self.whoami = None |
97 self.bridge = BridgeCall() | 103 self.bridge = BridgeCall() |
98 self.bridge_signals = BridgeSignals() | 104 self.bridge_signals = BridgeSignals(self) |
99 self.selected = None | 105 self.selected = None |
100 self.uni_box = None | 106 self.uni_box = None |
101 self.status_panel = panels.StatusPanel(self) | 107 self.status_panel = panels.StatusPanel(self) |
102 self.contact_panel = ContactPanel(self) | 108 self.contact_panel = ContactPanel(self) |
103 self.panel = panels.MainPanel(self) | 109 self.panel = panels.MainPanel(self) |
187 for contact in contacts_data: | 193 for contact in contacts_data: |
188 jid, attributes, groups = contact | 194 jid, attributes, groups = contact |
189 self._newContactCb(jid, attributes, groups) | 195 self._newContactCb(jid, attributes, groups) |
190 | 196 |
191 def _getSignalsCB(self, signal_data): | 197 def _getSignalsCB(self, signal_data): |
192 bridge_signals = BridgeSignals() | 198 self.bridge_signals.call('getSignals', self._getSignalsCB) |
193 bridge_signals.call('getSignals', self._getSignalsCB) | |
194 print('Got signal ==> name: %s, params: %s' % (signal_data[0],signal_data[1])) | 199 print('Got signal ==> name: %s, params: %s' % (signal_data[0],signal_data[1])) |
195 name,args = signal_data | 200 name,args = signal_data |
196 if name == 'personalEvent': | 201 if name == 'personalEvent': |
197 self._personalEventCb(*args) | 202 self._personalEventCb(*args) |
198 elif name == 'newMessage': | 203 elif name == 'newMessage': |