From a11aa3e0dd4df7d007352b4589a56674a70ea7e9 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Sun, 9 Jun 2019 11:35:31 -0700 Subject: [PATCH] WebSocket::send takes a third arg, binary which default to true (can be text too) --- CHANGELOG.md | 1 + ixwebsocket/IXWebSocket.cpp | 7 +++++-- ixwebsocket/IXWebSocket.h | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 184fb960..5a9ce327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - 2019-06-xx ### Changed +- WebSocket::send takes a third arg, binary which default to true (can be text too) - WebSocket callback only take one object, a const ix::WebSocketMessagePtr& msg - Add explicite WebSocket::sendBinary - New headers + WebSocketMessage class to hold message data, still not used across the board diff --git a/ixwebsocket/IXWebSocket.cpp b/ixwebsocket/IXWebSocket.cpp index 6d95d49b..5ff44d6c 100644 --- a/ixwebsocket/IXWebSocket.cpp +++ b/ixwebsocket/IXWebSocket.cpp @@ -385,9 +385,12 @@ namespace ix } WebSocketSendInfo WebSocket::send(const std::string& data, - const OnProgressCallback& onProgressCallback) + const OnProgressCallback& onProgressCallback, + bool binary) { - return sendMessage(data, SendMessageKind::Binary, onProgressCallback); + return sendMessage(data, + (binary) ? SendMessageKind::Binary: SendMessageKind::Text, + onProgressCallback); } WebSocketSendInfo WebSocket::sendBinary(const std::string& text, diff --git a/ixwebsocket/IXWebSocket.h b/ixwebsocket/IXWebSocket.h index 516ce673..22b50d98 100644 --- a/ixwebsocket/IXWebSocket.h +++ b/ixwebsocket/IXWebSocket.h @@ -66,7 +66,8 @@ namespace ix // send is in binary mode by default WebSocketSendInfo send(const std::string& data, - const OnProgressCallback& onProgressCallback = nullptr); + const OnProgressCallback& onProgressCallback = nullptr, + bool binary = true); WebSocketSendInfo sendBinary(const std::string& text, const OnProgressCallback& onProgressCallback = nullptr); WebSocketSendInfo sendText(const std::string& text,