def data_received()

in src/dubbo/remoting/aio/http2/protocol.py [0:0]


    def data_received(self, data):
        """
        Called when some data is received from the transport.
        :param data: The data received.
        :type data: bytes
        """
        # Update the last read time
        self._update_last_read()

        # Process the event
        events = self._h2_connection.receive_data(data)
        try:
            for event in events:
                frame = Http2EventUtils.convert_to_frame(event)

                # If frame is None, there are two possible cases:
                # 1. Events that are handled automatically by the H2 library (e.g. RemoteSettingsChanged, PingReceived).
                #    -> We just need to send it.
                # 2. Events that are not implemented or do not require attention. -> We'll ignore it for now.
                if frame is not None:
                    if isinstance(frame, WindowUpdateFrame):
                        # Because flow control may be at the connection level, it is handled here
                        self._flow_controller.release_flow_control(frame)
                    elif isinstance(frame, (HeadersFrame, DataFrame, RstStreamFrame)):
                        # Handle the frame by the stream handler
                        self._stream_handler.handle_frame(frame)
                    else:
                        # Try handling other frames
                        self._do_other_frame(frame)

                # Flush the data
                self._flush()

        except Exception as e:
            raise ProtocolError("Failed to process the Http/2 event.") from e