1 // SPDX-License-Identifier: Apache-2.0 2 // SPDX-FileCopyrightText: Copyright OpenBMC Authors 3 #pragma once 4 #include <boost/url/url_view.hpp> 5 6 #include <functional> 7 #include <memory> 8 #include <string_view> 9 10 namespace crow 11 { 12 namespace websocket 13 { 14 15 enum class MessageType 16 { 17 Binary, 18 Text, 19 }; 20 21 struct Connection : std::enable_shared_from_this<Connection> 22 { 23 public: 24 Connection() = default; 25 26 Connection(const Connection&) = delete; 27 Connection(Connection&&) = delete; 28 Connection& operator=(const Connection&) = delete; 29 Connection& operator=(const Connection&&) = delete; 30 31 virtual void sendBinary(std::string_view msg) = 0; 32 virtual void sendEx(MessageType type, std::string_view msg, 33 std::function<void()>&& onDone) = 0; 34 virtual void sendText(std::string_view msg) = 0; 35 virtual void close(std::string_view msg = "quit") = 0; 36 virtual void deferRead() = 0; 37 virtual void resumeRead() = 0; 38 virtual ~Connection() = default; 39 virtual boost::urls::url_view url() = 0; 40 }; 41 } // namespace websocket 42 } // namespace crow 43