24#include <seastar/core/seastar.hh>
25#include <seastar/core/iostream.hh>
26#include <seastar/core/queue.hh>
27#include <seastar/net/api.hh>
28#include <seastar/util/log.hh>
29#include <seastar/websocket/parser.hh>
31namespace seastar::experimental::websocket {
33extern sstring magic_key_suffix;
35using handler_t = std::function<future<>(input_stream<char>&, output_stream<char>&)>;
49 exception(std::string_view msg) : _msg(msg) {}
50 virtual const char* what()
const noexcept {
58class connection :
public boost::intrusive::list_base_hook<> {
74 return make_ready_future<buff_t>(std::move(f.
get()));
76 return current_exception_as_future<buff_t>();
83 return make_ready_future<>();
100 size_t buffer_size()
const noexcept override {
101 return data->max_size();
106 return make_ready_future<>();
121 static const size_t PIPE_SIZE = 512;
133 sstring _subprotocol;
141 , _read_buf(_fd.input())
142 , _write_buf(_fd.output())
143 , _input_buffer{PIPE_SIZE}
144 , _output_buffer{PIPE_SIZE}
147 std::make_unique<connection_source_impl>(&_input_buffer)}};
149 std::make_unique<connection_sink_impl>(&_output_buffer)}};
156 future<> close(
bool send_close =
true);
167std::string sha1_base64(std::string_view source);
168std::string encode_base64(std::string_view source);
170extern logger websocket_logger;
Definition: iostream.hh:105
Definition: iostream.hh:164
Definition: iostream.hh:62
Definition: iostream.hh:70
Implementation of connection's data sink.
Definition: common.hh:90
Implementation of connection's data source.
Definition: common.hh:65
a server WebSocket connection
Definition: common.hh:58
connection(connected_socket &&fd)
Definition: common.hh:139
future handle_ping()
This function processess received PING frame. https://datatracker.ietf.org/doc/html/rfc6455#section-5...
future handle_pong()
This function processess received PONG frame. https://datatracker.ietf.org/doc/html/rfc6455#section-5...
future send_data(opcodes opcode, temporary_buffer< char > &&buff)
Packs buff in websocket frame and sends it to the client.
void shutdown_input()
close the socket
an error in handling a WebSocket connection
Definition: common.hh:46
A representation of a possibly not-yet-computed value.
Definition: future.hh:1197
futurize_t< FuncResult > then_wrapped(Func &&func) &noexcept
Schedule a block of code to run when the future is ready, allowing for exception handling.
Definition: future.hh:1458
value_type && get()
gets the value returned by the computation
Definition: future.hh:1299
opcodes
Possible type of a websocket frame.
Definition: parser.hh:32