userver: samples/websocket_service/websocket_service.cpp
Loading...
Searching...
No Matches
samples/websocket_service/websocket_service.cpp
namespace samples::websocket {
class WebsocketsHandler final : public server::websocket::WebsocketHandlerBase {
public:
// `kName` is used as the component name in static config
static constexpr std::string_view kName = "websocket-handler";
// Component is valid after construction and is able to accept requests
using WebsocketHandlerBase::WebsocketHandlerBase;
chat.Recv(message);
if (message.close_status) break;
chat.Send(std::move(message));
}
if (message.close_status) chat.Close(*message.close_status);
}
};
} // namespace samples::websocket
int main(int argc, char* argv[]) {
const auto component_list =
.Append<samples::websocket::WebsocketsHandler>();
return utils::DaemonMain(argc, argv, component_list);
}