1 /** @file 2 * 3 * A brief file description 4 * 5 * @section license License 6 * 7 * Licensed to the Apache Software Foundation (ASF) under one 8 * or more contributor license agreements. See the NOTICE file 9 * distributed with this work for additional information 10 * regarding copyright ownership. The ASF licenses this file 11 * to you under the Apache License, Version 2.0 (the 12 * "License"); you may not use this file except in compliance 13 * with the License. You may obtain a copy of the License at 14 * 15 * http://www.apache.org/licenses/LICENSE-2.0 16 * 17 * Unless required by applicable law or agreed to in writing, software 18 * distributed under the License is distributed on an "AS IS" BASIS, 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 * See the License for the specific language governing permissions and 21 * limitations under the License. 22 */ 23 24 #pragma once 25 26 #include "QUICApplication.h" 27 #include "Http3Frame.h" 28 #include "Http3FrameHandler.h" 29 #include <vector> 30 31 class Http3FrameDispatcher 32 { 33 public: 34 Http3ErrorUPtr on_read_ready(QUICStreamIO &stream_io, uint64_t &nread); 35 36 void add_handler(Http3FrameHandler *handler); 37 38 private: 39 enum READING_STATE { 40 READING_TYPE_LEN, 41 READING_LENGTH_LEN, 42 READING_PAYLOAD_LEN, 43 READING_PAYLOAD, 44 } _reading_state = READING_TYPE_LEN; 45 int64_t _reading_frame_type_len; 46 int64_t _reading_frame_length_len; 47 uint64_t _reading_frame_payload_len; 48 Http3FrameFactory _frame_factory; 49 std::vector<Http3FrameHandler *> _handlers[256]; 50 }; 51