1 /* 2 * Copyright (c) 2015, 2021, Oracle and/or its affiliates. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License, version 2.0, 6 * as published by the Free Software Foundation. 7 * 8 * This program is also distributed with certain software (including 9 * but not limited to OpenSSL) that is licensed under separate terms, 10 * as designated in a particular file or component or in included license 11 * documentation. The authors of MySQL hereby grant you an additional 12 * permission to link the program and your derivative works with the 13 * separately licensed software that they have included with MySQL. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License, version 2.0, for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 23 * 02110-1301 USA 24 */ 25 26 #ifndef _NGS_SESSION_INTERFACE_H_ 27 #define _NGS_SESSION_INTERFACE_H_ 28 29 #include "ngs/protocol_authentication.h" 30 31 namespace ngs 32 { 33 34 class Request; 35 class Client_interface; 36 37 class Session_interface 38 { 39 public: 40 typedef int32_t Session_id; 41 42 enum State 43 { 44 // start as Authenticating 45 Authenticating, 46 // once authenticated, we can handle work 47 Ready, 48 // connection is closing, but wait for data to flush out first 49 Closing 50 }; 51 52 public: ~Session_interface()53 virtual ~Session_interface() { } 54 55 virtual Session_id session_id() const = 0; 56 virtual Error_code init() = 0; 57 58 public: 59 virtual void on_close(const bool update_old_state = false) = 0; 60 virtual void on_kill() = 0; 61 virtual void on_auth_success(const Authentication_handler::Response &response) = 0; 62 virtual void on_auth_failure(const Authentication_handler::Response &response) = 0; 63 64 // handle a single message, returns true if message was handled false if not 65 virtual bool handle_message(Request &command) = 0; 66 67 public: 68 virtual State state() const = 0; 69 virtual State state_before_close() const = 0; 70 71 virtual Client_interface &client() = 0; 72 73 virtual void mark_as_tls_session() = 0; 74 virtual bool is_handled_by(const void *handler) const = 0; 75 }; 76 77 } // namespace ngs 78 79 #endif // _NGS_SESSION_INTERFACE_H_ 80