コード例 #1
0
    def __connecting_httpgetplayerstatusres(self, container):
        self.log.trace()

        self.__save_playerstatus(container.message)
        server_type = ApiInfo.detectServerType(
            self.__live["playerstatus"]["addr"])
        self.__live[server_type] = True

        result = self.send_message(
            UnitId.SOCKETCTRL, EventId.SOCKETCONNECTREQ,
            SocketConnectReq(addr=self.__live["playerstatus"]["addr"],
                             port=self.__live["playerstatus"]["port"]))

        self.__live["block_no"] = ApiInfo.calculateBlockNo(
            no=self.__live["chat"]["no"])
        data = ApiInfo.createGetpostkeyUrl(
            thread=self.__live["playerstatus"]["thread"],
            block_no=self.__live["block_no"])

        result = self.send_message(UnitId.HTTPCTRL, EventId.HTTPGETPOSTKEYREQ,
                                   data)

        self.__send_timerreq_heartbeatreq(live_id=self.__live["liveId"])

        self.state = self.__StateId.CONNECTING
        return True
コード例 #2
0
    def __decide_whether_need_postkey(self, no=None):
        """ decide whether need postkey. """
        self.log.trace()
        if int(no) == 0:
            self.__live["chatCount"] += 1
        else:
            self.__live["chatCount"] = int(no)

        block_no = ApiInfo.calculateBlockNo(no=self.__live["chatCount"])
        if self.__live["block_no"] != block_no:
            self.__live["block_no"] = block_no
            return True
        else:
            return False
コード例 #3
0
    def __chatsending_chatresultnotify(self, container):
        self.log.trace()

        status = int(container.message.attrs["status"])
        if status == 0:
            self.__cleanupSendDataStore()

            result = self.send_message(UnitId.UNITCTRL, EventId.SENDCNF, None)

            data = self.__restoreSendDataStore()
            if data != None:
                chatTag = self.__create_chat_tag(data)

                result = self.send_message(
                    UnitId.SOCKETCTRL, EventId.SOCKETSENDREQ,
                    SocketSendReq(destination=self.__main_socket,
                                  data=chatTag))

                self.state = self.__StateId.CHATSENDING
                return True

            else:
                self.state = self.__StateId.IDLE
                return True

        elif status == 1:
            self.log.warning("chat_result fail[failure] (%s)",
                             container.message)

            self.__cleanupSendDataStore()

            self.state = self.__StateId.IDLE
            return True

        elif status == 2:
            self.log.warning("chat_result fail[thread id error] (%s)",
                             container.message)

            url = ApiInfo.createGetplayerstatusUrl(self.__live["liveId"])
            result = self.send_message(UnitId.HTTPCTRL,
                                       EventId.HTTPGETPLAYERSTATUSREQ, url)

            # TODO 再送処理は未実装
            # 状態をIDLEに戻す
            self.__cleanupSendDataStore()
            self.state = self.__StateId.IDLE
            return True

        elif status == 3:
            self.log.warning("chat_result fail[ticket error] (%s)",
                             container.message)

            threadTag = ApiInfo.createThreadTag(
                self.__live["playerstatus"]["thread"])
            result = self.send_message(
                UnitId.SOCKETCTRL, EventId.SOCKETSENDREQ,
                SocketSendReq(destination=self.__main_socket, data=threadTag))

            # TODO 再送処理は未実装
            # 状態をIDLEに戻す
            self.__cleanupSendDataStore()
            self.state = self.__StateId.IDLE
            return True

        elif status == 4:
            self.log.warning("chat_result fail[postkey error] (%s)",
                             container.message.attrs)

            self.__live["block_no"] = ApiInfo.calculateBlockNo(
                no=container.message.attrs["no"])
            url = ApiInfo.createGetpostkeyUrl(
                thread=self.__live["playerstatus"]["thread"],
                block_no=self.__live["block_no"])
            result = self.send_message(UnitId.HTTPCTRL,
                                       EventId.HTTPGETPOSTKEYREQ, url)

            self.state = self.__StateId.CHATSENDING
            return True

        elif status == 5:
            self.log.warning("chat_result fail[lock comment] (%s)",
                             container.message)

            self.__cleanupSendDataStore()

            self.state = self.__StateId.IDLE
            return True

        elif status == 8:
            self.log.warning("chat_result fail[long comment] (%s)",
                             container.message)

            self.__cleanupSendDataStore()

            self.state = self.__StateId.IDLE
            return True

        else:
            self.log.warning("chat_result fail[unknown error] (%s)",
                             container.message)

            self.__cleanupSendDataStore()

            self.state = self.__StateId.IDLE
            return True