Skip to content

Commit 7dd5eda

Browse files
Added maxMessageSize to C API
1 parent 0e81d72 commit 7dd5eda

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

include/rtc/configuration.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct WebSocketServerConfiguration {
112112
optional<string> keyPemPass;
113113
optional<string> bindAddress;
114114
optional<std::chrono::milliseconds> connectionTimeout;
115+
optional<size_t> maxMessageSize;
115116
};
116117

117118
#endif

include/rtc/rtc.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ typedef struct {
422422
int connectionTimeoutMs; // in milliseconds, 0 means default, < 0 means disabled
423423
int pingIntervalMs; // in milliseconds, 0 means default, < 0 means disabled
424424
int maxOutstandingPings; // 0 means default, < 0 means disabled
425+
int maxMessageSize; // <= 0 means default
425426
} rtcWsConfiguration;
426427

427428
RTC_C_EXPORT int rtcCreateWebSocket(const char *url); // returns ws id
@@ -441,8 +442,9 @@ typedef struct {
441442
const char *certificatePemFile; // NULL for autogenerated certificate
442443
const char *keyPemFile; // NULL for autogenerated certificate
443444
const char *keyPemPass; // NULL if no pass
444-
const char *bindAddress; // NULL for IP_ANY_ADDR
445+
const char *bindAddress; // NULL for any
445446
int connectionTimeoutMs; // in milliseconds, 0 means default, < 0 means disabled
447+
int maxMessageSize; // <= 0 means default
446448
} rtcWsServerConfiguration;
447449

448450
RTC_C_EXPORT int rtcCreateWebSocketServer(const rtcWsServerConfiguration *config,

src/capi.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,9 @@ int rtcCreateWebSocketEx(const char *url, const rtcWsConfiguration *config) {
14791479
else if (config->maxOutstandingPings < 0)
14801480
c.maxOutstandingPings = 0; // setting to 0 disables, not setting keeps default
14811481

1482+
if(config->maxMessageSize > 0)
1483+
c.maxMessageSize = size_t(config->maxMessageSize);
1484+
14821485
auto webSocket = std::make_shared<WebSocket>(std::move(c));
14831486
webSocket->open(url);
14841487
return emplaceWebSocket(webSocket);
@@ -1533,6 +1536,10 @@ RTC_C_EXPORT int rtcCreateWebSocketServer(const rtcWsServerConfiguration *config
15331536
c.keyPemFile = config->keyPemFile ? make_optional(string(config->keyPemFile)) : nullopt;
15341537
c.keyPemPass = config->keyPemPass ? make_optional(string(config->keyPemPass)) : nullopt;
15351538
c.bindAddress = config->bindAddress ? make_optional(string(config->bindAddress)) : nullopt;
1539+
1540+
if(config->maxMessageSize > 0)
1541+
c.maxMessageSize = size_t(config->maxMessageSize);
1542+
15361543
auto webSocketServer = std::make_shared<WebSocketServer>(std::move(c));
15371544
int wsserver = emplaceWebSocketServer(webSocketServer);
15381545

src/impl/websocketserver.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void WebSocketServer::runLoop() {
7979

8080
WebSocket::Configuration clientConfig;
8181
clientConfig.connectionTimeout = config.connectionTimeout;
82+
clientConfig.maxMessageSize = config.maxMessageSize;
8283

8384
auto impl = std::make_shared<WebSocket>(std::move(clientConfig), mCertificate);
8485
impl->changeState(WebSocket::State::Connecting);

0 commit comments

Comments
 (0)