| Ed Tanous | 40e9b92 | 2024-09-10 13:50:16 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 | 
|  | 2 | // SPDX-FileCopyrightText: Copyright OpenBMC Authors | 
| Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 3 | #pragma once | 
| Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 4 | #include <boost/url/url_view.hpp> | 
|  | 5 |  | 
| Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 6 | #include <functional> | 
| Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 7 | #include <memory> | 
| Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 8 | #include <string_view> | 
| Ed Tanous | 1b0044b | 2018-08-03 14:30:05 -0700 | [diff] [blame] | 9 |  | 
| Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 10 | namespace crow | 
|  | 11 | { | 
|  | 12 | namespace websocket | 
|  | 13 | { | 
| Iwona Klimaszewska | c0a1c8a | 2019-07-12 18:26:38 +0200 | [diff] [blame] | 14 |  | 
| Ed Tanous | 863c1c2 | 2022-02-21 21:33:06 -0800 | [diff] [blame] | 15 | enum class MessageType | 
|  | 16 | { | 
|  | 17 | Binary, | 
|  | 18 | Text, | 
|  | 19 | }; | 
|  | 20 |  | 
| Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 21 | struct Connection : std::enable_shared_from_this<Connection> | 
|  | 22 | { | 
|  | 23 | public: | 
| Ed Tanous | 5ebb9d3 | 2023-02-27 18:20:47 -0800 | [diff] [blame] | 24 | Connection() = default; | 
| Przemyslaw Czarnowski | 250b0eb | 2020-02-24 10:23:56 +0100 | [diff] [blame] | 25 |  | 
| Ed Tanous | ecd6a3a | 2022-01-07 09:18:40 -0800 | [diff] [blame] | 26 | Connection(const Connection&) = delete; | 
|  | 27 | Connection(Connection&&) = delete; | 
|  | 28 | Connection& operator=(const Connection&) = delete; | 
|  | 29 | Connection& operator=(const Connection&&) = delete; | 
|  | 30 |  | 
| Ed Tanous | 9eb808c | 2022-01-25 10:19:23 -0800 | [diff] [blame] | 31 | virtual void sendBinary(std::string_view msg) = 0; | 
| Ed Tanous | 863c1c2 | 2022-02-21 21:33:06 -0800 | [diff] [blame] | 32 | virtual void sendEx(MessageType type, std::string_view msg, | 
|  | 33 | std::function<void()>&& onDone) = 0; | 
| Ed Tanous | 9eb808c | 2022-01-25 10:19:23 -0800 | [diff] [blame] | 34 | virtual void sendText(std::string_view msg) = 0; | 
| Ed Tanous | 9eb808c | 2022-01-25 10:19:23 -0800 | [diff] [blame] | 35 | virtual void close(std::string_view msg = "quit") = 0; | 
| Ed Tanous | 863c1c2 | 2022-02-21 21:33:06 -0800 | [diff] [blame] | 36 | virtual void deferRead() = 0; | 
|  | 37 | virtual void resumeRead() = 0; | 
| Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 38 | virtual ~Connection() = default; | 
| Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 39 | virtual boost::urls::url_view url() = 0; | 
| Ed Tanous | 7045c8d | 2017-04-03 10:04:37 -0700 | [diff] [blame] | 40 | }; | 
| Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 41 | } // namespace websocket | 
|  | 42 | } // namespace crow |