(ixwebsocket) Expose setHandshakeTimeout method

This commit is contained in:
Benjamin Sergeant
2021-03-07 19:29:28 -08:00
parent 7c195219cd
commit f090c7659b
6 changed files with 37 additions and 33 deletions

View File

@ -175,30 +175,29 @@ namespace ix
//
void WebSocketServer::makeBroadcastServer()
{
setOnClientMessageCallback(
[this](std::shared_ptr<ConnectionState> connectionState,
WebSocket& webSocket,
const WebSocketMessagePtr& msg) {
auto remoteIp = connectionState->getRemoteIp();
if (msg->type == ix::WebSocketMessageType::Message)
setOnClientMessageCallback([this](std::shared_ptr<ConnectionState> connectionState,
WebSocket& webSocket,
const WebSocketMessagePtr& msg) {
auto remoteIp = connectionState->getRemoteIp();
if (msg->type == ix::WebSocketMessageType::Message)
{
for (auto&& client : getClients())
{
for (auto&& client : getClients())
if (client.get() != &webSocket)
{
if (client.get() != &webSocket)
{
client->send(msg->str, msg->binary);
client->send(msg->str, msg->binary);
// Make sure the OS send buffer is flushed before moving on
do
{
size_t bufferedAmount = client->bufferedAmount();
std::chrono::duration<double, std::milli> duration(500);
std::this_thread::sleep_for(duration);
} while (client->bufferedAmount() != 0);
}
// Make sure the OS send buffer is flushed before moving on
do
{
size_t bufferedAmount = client->bufferedAmount();
std::chrono::duration<double, std::milli> duration(500);
std::this_thread::sleep_for(duration);
} while (client->bufferedAmount() != 0);
}
}
});
}
});
}
int WebSocketServer::listenAndStart()

View File

@ -6,4 +6,4 @@
#pragma once
#define IX_WEBSOCKET_VERSION "11.0.8"
#define IX_WEBSOCKET_VERSION "11.0.9"