Mercurial > libervia-web
changeset 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 | 6947450a477b |
files | browser_side/menu.py libervia.py |
diffstat | 2 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/browser_side/menu.py Sat Jan 05 16:07:33 2013 +0100 +++ b/browser_side/menu.py Sat Jan 05 16:08:25 2013 +0100 @@ -127,8 +127,7 @@ _item_tpl = "<img src='media/icons/menu/%s_menu_red.png' />%s" menu_general = MenuBar(vertical=True) - menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract")) - menu_general.addItem("About", MenuCmd(self, "onAbout")) + menu_general.addItem("Disconnect", MenuCmd(self, "onDisconnect")) menu_contacts = MenuBar(vertical=True) menu_contacts.addItem("add contact", MenuCmd(self, "onAddContact")) @@ -170,6 +169,14 @@ self.add(menubar) #General menu + def onDisconnect(self): + def confirm_cb(answer): + if answer: + print "déconnexion" + self.host.bridge.call('disconnect', None) + _dialog = dialog.ConfirmDialog(confirm_cb, text="Do you really want to disconnect ?") + _dialog.show() + def onSocialContract(self): _frame = Frame('contrat_social.html') _frame.setStyleName('infoFrame')
--- a/libervia.py Sat Jan 05 16:07:33 2013 +0100 +++ b/libervia.py Sat Jan 05 16:08:25 2013 +0100 @@ -86,7 +86,7 @@ "joinMUC", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getEntityData", "getParamsUI", #"setParam", - "launchAction", + "launchAction", "disconnect", ]) class BridgeSignals(LiberviaJsonProxy): @@ -104,7 +104,10 @@ def onRemoteError(self, code, errobj, request_info): - LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info) + if errobj['message'] == 'Empty Response': + Window.getLocation().reload() # XXX: reset page in case of session ended. + # FIXME: Should be done more properly without hard reload + LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info) #we now try to reconnect if isinstance(errobj['message'],dict) and errobj['message']['faultCode']==0: Window.alert('You are not allowed to connect to server')