Example #1
0
    def onJoinRaidButton(self, event):
        if not raid.isInRaid():
            # Encode key to ascii (for wx unicode)
            key = self.keyBox.GetValue().encode('ascii')

            self.addToConsole("Joining raid with key '%s'..."%(key))

            self.keyStatus.SetLabel("Joining raid...")
            self.keyBox.SetEditable(False)
            self.keyJoinButton.Disable()
            self.keyGenerateButton.Disable()
            self.keyVanityCheck.Disable()

            raid.joinRaid(key, self.onJoinedRaid, self.onFailedToJoinRaid)
        else:
            raid.leaveRaid()
            self.onLeftRaid()
Example #2
0
    def run(self):
        prnt("RaidClient: Booting up...")

        self.conn = net.node.connect(self.serverNode, "swap:raid")
        if not self.conn or self.conn.state != fuzion.CS_CONNECTED:
            raid.leaveRaid()
            wx.CallAfter(self.failureFunc, "node_connect_failed")
            prnt("RaidClient: Connection failed, shutting down...")
            return

        # Inform the UI of raid join success.
        wx.CallAfter(self.successFunc)

        while not self.stoppedEvent.isSet():
            if self.pausedEvent.isSet():
                sleep(0.4)
                continue

            if self.conn.recvPending():
                data = self.conn.recv()
                if data == None:
                    if self.conn.closedReason != 0:
                        # If we're paused, we don't want to reconnect yet.
                        if self.pausedEvent.isSet():
                            continue

                        prnt("RaidClient: Connection lost, reason=%s"%fuzion.formatError(self.conn.closedReason))

                        # Fetch new raid info
                        self.serverNode = None
                        self.conn = None
                        while self.serverNode == None or self.conn == None:
                            prnt("RaidClient: Reconnecting...")
                            self.serverNode = raid.getNewServerNode()
                            if self.serverNode == None:
                                prnt("RaidClient: Failed to get new server node...")
                                sleep(2)
                                continue
                            conn = net.node.connect(self.serverNode, "swap:raid")
                            if conn.state == fuzion.CS_CONNECTED:
                                self.conn = conn
                                self.lastTicks = 2
                                continue
                            else:
                                prnt("RaidClient: Failed to connect to new node! Connection state = %d"%conn.state)
                            sleep(2)
                    continue
                packet = data.readByte()
                if packet == pkt.RAID_UPDATE:
                    self.gotRaidUpdate(data)

            now = time()
            if now - self.lastUpdateSent >= 2 and (log_parser.get().inCombat or self.lastTicks >= 1):
                if not log_parser.get().inCombat:
                    self.lastTicks -= 1
                else:
                    self.lastTicks = 2
                self.sendPlayerUpdate()
                self.lastUpdateSent = now
            sleep(0.1)

        self.conn.close()

        prnt("RaidClient: Shutting down...")
Example #3
0
 def onClose(self, event):
     if raid.isInRaid():
         raid.leaveRaid()
     log_analyzer.get().unregisterFrame(self)
     overlays.killAllOverlays()
     self.Destroy()
Example #4
0
    def run(self):
        prnt("RaidClient: Booting up...")

        self.conn = net.node.connect(self.serverNode, "swap:raid")
        if not self.conn or self.conn.state != fuzion.CS_CONNECTED:
            raid.leaveRaid()
            wx.CallAfter(self.failureFunc, "node_connect_failed")
            prnt("RaidClient: Connection failed, shutting down...")
            return

        # Inform the UI of raid join success.
        wx.CallAfter(self.successFunc)

        while not self.stoppedEvent.isSet():
            if self.pausedEvent.isSet():
                sleep(0.4)
                continue

            if self.conn.recvPending():
                data = self.conn.recv()
                if data == None:
                    if self.conn.closedReason != 0:
                        # If we're paused, we don't want to reconnect yet.
                        if self.pausedEvent.isSet():
                            continue

                        prnt("RaidClient: Connection lost, reason=%s" %
                             fuzion.formatError(self.conn.closedReason))

                        # Fetch new raid info
                        self.serverNode = None
                        self.conn = None
                        while self.serverNode == None or self.conn == None:
                            prnt("RaidClient: Reconnecting...")
                            self.serverNode = raid.getNewServerNode()
                            if self.serverNode == None:
                                prnt(
                                    "RaidClient: Failed to get new server node..."
                                )
                                sleep(2)
                                continue
                            conn = net.node.connect(self.serverNode,
                                                    "swap:raid")
                            if conn.state == fuzion.CS_CONNECTED:
                                self.conn = conn
                                self.lastTicks = 2
                                continue
                            else:
                                prnt(
                                    "RaidClient: Failed to connect to new node! Connection state = %d"
                                    % conn.state)
                            sleep(2)
                    continue
                packet = data.readByte()
                if packet == pkt.RAID_UPDATE:
                    self.gotRaidUpdate(data)

            now = time()
            if now - self.lastUpdateSent >= 2 and (log_parser.get().inCombat
                                                   or self.lastTicks >= 1):
                if not log_parser.get().inCombat:
                    self.lastTicks -= 1
                else:
                    self.lastTicks = 2
                self.sendPlayerUpdate()
                self.lastUpdateSent = now
            sleep(0.1)

        self.conn.close()

        prnt("RaidClient: Shutting down...")