コード例 #1
0
 def _SendAck(self):
   """Send an ACK back to server."""
   if self._total_bytes_received > self._total_bytes_received_and_acked:
     bytes_received = self._total_bytes_received
     try:
       ack_data = utils.CreateSubprotocolAckFrame(bytes_received)
       self._websocket_helper.Send(ack_data)
       self._total_bytes_received_and_acked = bytes_received
     except helper.WebSocketConnectionClosed:
       pass
     except EnvironmentError as e:
       log.info('Unable to send WebSocket ack [%s]', str(e))
     except:  # pylint: disable=bare-except
       if not self._IsClosed():
         log.info('Error while attempting to ack [%d] bytes', bytes_received,
                  exc_info=True)
コード例 #2
0
 def testCreateSubprotocolAckFrame(self, ack_bytes, expected_bytes):
     self.assertEqual(utils.CreateSubprotocolAckFrame(ack_bytes),
                      expected_bytes)
コード例 #3
0
 def testCreateSubprotocolAckFrameInvalidInput(self, ack_bytes,
                                               expected_error):
     with self.AssertRaisesExceptionMatches(expected_error, ''):
         utils.CreateSubprotocolAckFrame(ack_bytes)
コード例 #4
0
 def _SendAck(self):
     if self._total_bytes_received:
         ack_data = utils.CreateSubprotocolAckFrame(
             self._total_bytes_received)
         self._SendBytes(ack_data)