comparison libervia.py @ 158:58442ed28f2b

browser side: basic disconnection management: hard reload is done on empty signal response
author Goffi <goffi@goffi.org>
date Sat, 05 Jan 2013 16:08:25 +0100
parents b17ec3a6a112
children b887186e8fc8
comparison
equal deleted inserted replaced
157:b17ec3a6a112 158:58442ed28f2b
84 LiberviaJsonProxy.__init__(self, "/json_api", 84 LiberviaJsonProxy.__init__(self, "/json_api",
85 ["getContacts", "addContact", "sendMessage", "sendMblog", "getLastMblogs", "getMassiveLastMblogs", "getProfileJid", "getHistory", "getPresenceStatus", 85 ["getContacts", "addContact", "sendMessage", "sendMblog", "getLastMblogs", "getMassiveLastMblogs", "getProfileJid", "getHistory", "getPresenceStatus",
86 "joinMUC", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", 86 "joinMUC", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed",
87 "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getEntityData", "getParamsUI", 87 "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getEntityData", "getParamsUI",
88 #"setParam", 88 #"setParam",
89 "launchAction", 89 "launchAction", "disconnect",
90 ]) 90 ])
91 91
92 class BridgeSignals(LiberviaJsonProxy): 92 class BridgeSignals(LiberviaJsonProxy):
93 RETRY_BASE_DELAY = 1000 93 RETRY_BASE_DELAY = 1000
94 94
102 self.retry_delay = self.RETRY_BASE_DELAY 102 self.retry_delay = self.RETRY_BASE_DELAY
103 LiberviaJsonProxy.onRemoteResponse(self, response, request_info) 103 LiberviaJsonProxy.onRemoteResponse(self, response, request_info)
104 104
105 105
106 def onRemoteError(self, code, errobj, request_info): 106 def onRemoteError(self, code, errobj, request_info):
107 LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info) 107 if errobj['message'] == 'Empty Response':
108 Window.getLocation().reload() # XXX: reset page in case of session ended.
109 # FIXME: Should be done more properly without hard reload
110 LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info)
108 #we now try to reconnect 111 #we now try to reconnect
109 if isinstance(errobj['message'],dict) and errobj['message']['faultCode']==0: 112 if isinstance(errobj['message'],dict) and errobj['message']['faultCode']==0:
110 Window.alert('You are not allowed to connect to server') 113 Window.alert('You are not allowed to connect to server')
111 else: 114 else:
112 def _timerCb(): 115 def _timerCb():