Пример #1
0
 def testExtractSubprotocolReconnectSuccessAck(self, binary_data,
                                               expected_data,
                                               expected_bytes_left):
     data, bytes_left = utils.ExtractSubprotocolReconnectSuccessAck(
         binary_data)
     self.assertEqual(data, expected_data)
     self.assertEqual(bytes_left, expected_bytes_left)
    def _HandleSubprotocolReconnectSuccessAck(self, binary_data):
        """Handle Subprotocol RECONNECT_SUCCESS_ACK Frame."""
        if self._HasConnected():
            self._StopConnectionAsync()
            raise SubprotocolExtraReconnectSuccessAck(
                'Received RECONNECT_SUCCESS_ACK after already connected.')

        bytes_confirmed, bytes_left = (
            utils.ExtractSubprotocolReconnectSuccessAck(binary_data))
        bytes_being_confirmed = bytes_confirmed - self._total_bytes_confirmed
        self._ConfirmData(bytes_confirmed)
        log.info(
            'Reconnecting: confirming [%d] bytes and resending [%d] messages.',
            bytes_being_confirmed, len(self._unconfirmed_data))
        self._AddUnconfirmedDataBackToTheQueue()
        self._connect_msg_received = True
        if bytes_left:
            log.debug(
                'Discarding [%d] extra bytes after processing RECONNECT_SUCCESS_ACK',
                len(bytes_left))
Пример #3
0
    def _HandleSubprotocolReconnectSuccessAck(self, binary_data):
        """Handle Subprotocol RECONNECT_SUCCESS_ACK Frame."""
        if self._HasConnected():
            self._StopConnectionAsync()
            raise SubprotocolExtraReconnectSuccessAck(
                'Received RECONNECT_SUCCESS_ACK after already connected.')

        bytes_confirmed, bytes_left = (
            utils.ExtractSubprotocolReconnectSuccessAck(binary_data))
        bytes_being_confirmed = bytes_confirmed - self._total_bytes_confirmed
        self._ConfirmData(bytes_confirmed)
        log.info(
            'Reconnecting: confirming [%d] bytes and resending [%d] messages.',
            bytes_being_confirmed, len(self._unconfirmed_data))
        self._unsent_data.extendleft(reversed(self._unconfirmed_data))
        self._unconfirmed_data = deque()
        self._connect_msg_received = True
        if bytes_left and log.GetVerbosity() == logging.DEBUG:
            log.info(
                'Discarding [%d] extra bytes after processing RECONNECT_SUCCESS_ACK',
                len(bytes_left))
Пример #4
0
 def testExtractSubprotocolReconnectSuccessAckIncompleteData(
         self, binary_data, expected_error):
     with self.AssertRaisesExceptionMatches(expected_error, ''):
         utils.ExtractSubprotocolReconnectSuccessAck(binary_data)