def handleAction(self, model, entityID, action): super(AcceptPrbInviteHandler, self).handleAction(model, entityID, action) yield lambda callback: callback(None) postActions = [] invite = self.prbInvites.getInvite(entityID) state = self.prbDispatcher.getFunctionalState() if state.doLeaveToAcceptInvite(invite.type): postActions.append(actions.LeavePrbModalEntity()) if invite and invite.anotherPeriphery: success = True if g_preDefinedHosts.isRoamingPeriphery(invite.peripheryID): success = yield DialogsInterface.showI18nConfirmDialog( 'changeRoamingPeriphery') if not success: return postActions.append(actions.DisconnectFromPeriphery()) postActions.append(actions.ConnectToPeriphery(invite.peripheryID)) postActions.append(actions.PrbInvitesInit()) postActions.append(actions.LeavePrbEntity()) g_eventBus.handleEvent(events.PrbInvitesEvent( events.PrbInvitesEvent.ACCEPT, inviteID=entityID, postActions=postActions), scope=EVENT_BUS_SCOPE.LOBBY)
def join(self, peripheryID, ctx, postActions=None, finishActions=None): if not g_lobbyContext.isAnotherPeriphery(peripheryID): LOG_ERROR('Player is in given periphery', peripheryID) return else: if postActions: if type(postActions) is types.ListType: actionsList = postActions else: LOG_ERROR('Argument "postActions" is invalid', postActions) return else: actionsList = [] actionsList.extend([ actions.DisconnectFromPeriphery(), actions.ConnectToPeriphery(peripheryID), self.__enableAction ]) if finishActions: if type(finishActions) is types.ListType: actionsList.extend(finishActions) else: LOG_ERROR('Argument "finishActions" is invalid', finishActions) return self.__joinCtx = ctx if self.__joinChain is not None: self.__joinChain.onStopped -= self.__onJoinChainStopped self.__joinChain.stop() self.__enableAction.inactivate() self.__joinChain = actions.ActionsChain(actionsList) self.__joinChain.onStopped += self.__onJoinChainStopped self.__joinChain.start() return
def doRelogin(self, peripheryID, onStoppedHandler = None, extraChainSteps = None): from gui.shared import actions LOG_DEBUG('Attempt to relogin to the another periphery', peripheryID) chain = [actions.LeavePrbModalEntity(), actions.DisconnectFromPeriphery(), actions.ConnectToPeriphery(peripheryID)] if extraChainSteps is not None: chain += extraChainSteps self.__reloginStoppedHandler = onStoppedHandler self.__reloginChain = actions.ActionsChain(chain) self.__reloginChain.onStopped += self.__onReloginStopped self.__reloginChain.start() return
def join(self, peripheryID, ctx, postActions=None, finishActions=None): """ Join to prebattle/unit that is on another periphery. Args: peripheryID: periphery identifier ctx: join request context postActions: post actions chain finishActions: finish actions chain """ if not self.lobbyContext.isAnotherPeriphery(peripheryID): LOG_ERROR('Player is in given periphery', peripheryID) return else: if postActions: if isinstance(postActions, types.ListType): actionsList = postActions else: LOG_ERROR('Argument "postActions" is invalid', postActions) return else: actionsList = [] actionsList.extend([ actions.DisconnectFromPeriphery(), actions.ConnectToPeriphery(peripheryID), self.__enableAction ]) if finishActions: if isinstance(finishActions, types.ListType): actionsList.extend(finishActions) else: LOG_ERROR('Argument "finishActions" is invalid', finishActions) return self.__joinCtx = ctx if self.__joinChain is not None: self.__joinChain.onStopped -= self.__onJoinChainStopped self.__joinChain.stop() self.__enableAction.inactivate() self.__joinChain = actions.ActionsChain(actionsList) self.__joinChain.onStopped += self.__onJoinChainStopped self.__joinChain.start() return