comparison src/browser/sat_browser/json.py @ 642:5af02673d047 frontends_multi_profiles

browser side (json): replaced the Window.alert by a log warning when signal is lost
author Goffi <goffi@goffi.org>
date Tue, 24 Feb 2015 19:15:07 +0100
parents 917e271975d9
children 849ffb24d5bf
comparison
equal deleted inserted replaced
641:f5145881723a 642:5af02673d047
221 self.retry_delay = self.RETRY_BASE_DELAY 221 self.retry_delay = self.RETRY_BASE_DELAY
222 LiberviaJsonProxy.onRemoteResponse(self, response, request_info) 222 LiberviaJsonProxy.onRemoteResponse(self, response, request_info)
223 223
224 def onRemoteError(self, code, errobj, request_info): 224 def onRemoteError(self, code, errobj, request_info):
225 if errobj['message'] == 'Empty Response': 225 if errobj['message'] == 'Empty Response':
226 Window.alert (u"Empty reponse bridgeSignal\ncode={}\nrequest_info: id={} method={} handler={}".format(code, request_info.id, request_info.method, request_info.handler)) 226 log.warning(u"Empty reponse bridgeSignal\ncode={}\nrequest_info: id={} method={} handler={}".format(code, request_info.id, request_info.method, request_info.handler))
227 # FIXME: to check/replace by a proper session end on disconnected signal 227 # FIXME: to check/replace by a proper session end on disconnected signal
228 # Window.getLocation().reload() # XXX: reset page in case of session ended. 228 # Window.getLocation().reload() # XXX: reset page in case of session ended.
229 # FIXME: Should be done more properly without hard reload 229 # FIXME: Should be done more properly without hard reload
230 LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info) 230 LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info)
231 #we now try to reconnect 231 #we now try to reconnect
233 Window.alert('You are not allowed to connect to server') 233 Window.alert('You are not allowed to connect to server')
234 else: 234 else:
235 def _timerCb(timer): 235 def _timerCb(timer):
236 log.info("Trying to reconnect to server...") 236 log.info("Trying to reconnect to server...")
237 self.getSignals(callback=self.signalHandler) 237 self.getSignals(callback=self.signalHandler)
238 # TODO: display a notification to user
238 log.warning("Lost connection, trying to reconnect in {} s".format(self.retry_delay/1000)) 239 log.warning("Lost connection, trying to reconnect in {} s".format(self.retry_delay/1000))
239 Timer(notify=_timerCb).schedule(self.retry_delay) 240 Timer(notify=_timerCb).schedule(self.retry_delay)
240 self.retry_delay *= 2 241 self.retry_delay *= 2
241 242
242 def register(self, name, callback, with_profile=True): 243 def register(self, name, callback, with_profile=True):