# File lib/websocket/frame/handler/handler03.rb, line 41
        def decode_frame
          while @frame.data.size > 1
            valid_header, more, frame_type, mask, payload_length = decode_header
            return unless valid_header

            application_data = decode_payload(payload_length, mask)

            if more
              decode_continuation_frame(application_data, frame_type)
            elsif frame_type == :continuation
              return decode_finish_continuation_frame(application_data)
            else
              raise(WebSocket::Error::Frame::InvalidPayloadEncoding) if frame_type == :text && !application_data.valid_encoding?
              return @frame.class.new(version: @frame.version, type: frame_type, data: application_data, decoded: true)
            end
          end
          nil
        end