00001 /** @file 00002 00003 Http2ConnectionState. 00004 00005 @section license License 00006 00007 Licensed to the Apache Software Foundation (ASF) under one 00008 or more contributor license agreements. See the NOTICE file 00009 distributed with this work for additional information 00010 regarding copyright ownership. The ASF licenses this file 00011 to you under the Apache License, Version 2.0 (the 00012 "License"); you may not use this file except in compliance 00013 with the License. You may obtain a copy of the License at 00014 00015 http://www.apache.org/licenses/LICENSE-2.0 00016 00017 Unless required by applicable law or agreed to in writing, software 00018 distributed under the License is distributed on an "AS IS" BASIS, 00019 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 See the License for the specific language governing permissions and 00021 limitations under the License. 00022 */ 00023 00024 #ifndef __HTTP2_CONNECTION_STATE_H__ 00025 #define __HTTP2_CONNECTION_STATE_H__ 00026 00027 #include "HTTP2.h" 00028 00029 class Http2ClientSession; 00030 00031 class Http2ConnectionSettings 00032 { 00033 public: 00034 unsigned get(Http2SettingsIdentifier id) const { 00035 return this->settings[indexof(id)]; 00036 } 00037 00038 unsigned set(Http2SettingsIdentifier id, unsigned value) { 00039 return this->settings[indexof(id)] = value; 00040 } 00041 00042 private: 00043 00044 // Settings ID is 1-based, so convert it to a 0-based index. 00045 static unsigned indexof(Http2SettingsIdentifier id) { 00046 return id - 1; 00047 } 00048 00049 unsigned settings[HTTP2_SETTINGS_MAX - 1]; 00050 }; 00051 00052 // Http2ConnectionState 00053 // 00054 // Capture the semantics of a HTTP/2 connection. The client session captures the frame layer, and the 00055 // connection state captures the connection-wide state. 00056 00057 class Http2ConnectionState : public Continuation 00058 { 00059 public: 00060 00061 Http2ConnectionState() : Continuation(NULL), ua_session(NULL) { 00062 SET_HANDLER(&Http2ConnectionState::main_event_handler); 00063 } 00064 00065 Http2ClientSession * ua_session; 00066 00067 // Settings. 00068 Http2ConnectionSettings server_settings; 00069 Http2ConnectionSettings client_settings; 00070 00071 int main_event_handler(int, void *); 00072 int state_closed(int, void *); 00073 00074 private: 00075 Http2ConnectionState(const Http2ConnectionState&); // noncopyable 00076 Http2ConnectionState& operator=(const Http2ConnectionState&); // noncopyable 00077 }; 00078 00079 #endif // __HTTP2_CONNECTION_STATE_H__