Mercurial > libervia-web
comparison libervia.py @ 157:b17ec3a6a112
browser side: in case of error, retry delay is doubled at each try
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 05 Jan 2013 16:07:33 +0100 |
parents | 8635bc9db9bf |
children | 58442ed28f2b |
comparison
equal
deleted
inserted
replaced
156:46835a4e2551 | 157:b17ec3a6a112 |
---|---|
88 #"setParam", | 88 #"setParam", |
89 "launchAction", | 89 "launchAction", |
90 ]) | 90 ]) |
91 | 91 |
92 class BridgeSignals(LiberviaJsonProxy): | 92 class BridgeSignals(LiberviaJsonProxy): |
93 RETRY_BASE_DELAY = 1000 | |
94 | |
93 def __init__(self, host): | 95 def __init__(self, host): |
94 self.host = host | 96 self.host = host |
97 self.retry_delay = self.RETRY_BASE_DELAY | |
95 LiberviaJsonProxy.__init__(self, "/json_signal_api", | 98 LiberviaJsonProxy.__init__(self, "/json_signal_api", |
96 ["getSignals"]) | 99 ["getSignals"]) |
100 | |
101 def onRemoteResponse(self, response, request_info): | |
102 self.retry_delay = self.RETRY_BASE_DELAY | |
103 LiberviaJsonProxy.onRemoteResponse(self, response, request_info) | |
104 | |
97 | 105 |
98 def onRemoteError(self, code, errobj, request_info): | 106 def onRemoteError(self, code, errobj, request_info): |
99 LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info) | 107 LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info) |
100 #we now try to reconnect | 108 #we now try to reconnect |
101 if isinstance(errobj['message'],dict) and errobj['message']['faultCode']==0: | 109 if isinstance(errobj['message'],dict) and errobj['message']['faultCode']==0: |
102 Window.alert('You are not allowed to connect to server') | 110 Window.alert('You are not allowed to connect to server') |
103 else: | 111 else: |
104 def _timerCb(): | 112 def _timerCb(): |
105 self.host.bridge_signals.call('getSignals', self.host._getSignalsCB) | 113 self.host.bridge_signals.call('getSignals', self.host._getSignalsCB) |
106 Timer(notify=_timerCb).schedule(5000) #we wait 5 s and try again | 114 Timer(notify=_timerCb).schedule(self.retry_delay) |
115 self.retry_delay *= 2 | |
107 | 116 |
108 class SatWebFrontend: | 117 class SatWebFrontend: |
109 def onModuleLoad(self): | 118 def onModuleLoad(self): |
110 print "============ onModuleLoad ==============" | 119 print "============ onModuleLoad ==============" |
111 self.whoami = None | 120 self.whoami = None |