Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/oatpp-websocket/WebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,10 @@ void WebSocket::sendOneFrameBinary(const oatpp::String& message) const {
throw std::runtime_error("[oatpp::web::protocol::websocket::WebSocket::sendOneFrameBinary()]: Unknown error while writing to socket.");
}
}


void WebSocket::sendOneFrameDto(const Void &dto,
const std::shared_ptr<oatpp::data::mapping::ObjectMapper> &objectMapper) const {
sendOneFrameText(objectMapper->writeToString(dto));
}

}}
9 changes: 9 additions & 0 deletions src/oatpp-websocket/WebSocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "oatpp/core/data/stream/BufferStream.hpp"
#include "oatpp/core/provider/Provider.hpp"
#include "oatpp/core/data/mapping/ObjectMapper.hpp"
#include "oatpp/core/macro/component.hpp"

namespace oatpp { namespace websocket {

Expand Down Expand Up @@ -271,6 +273,13 @@ class WebSocket : public oatpp::base::Countable {
* @throws - `runtime_error`.
*/
void sendOneFrameBinary(const oatpp::String& message) const;

/**
* Send one-frame dto message.
* @param message - message dto. &id:oatpp::data::mapping::type::Void;.
* @throws - `runtime_error`.
*/
void sendOneFrameDto(const oatpp::data::mapping::type::Void& dto, const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& objectMapper = OATPP_GET_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>)) const;

};

Expand Down