(ws) port broadcast_server sub-command to the new server API
This commit is contained in:
parent
c14a4c0e3e
commit
e34f1c30d6
@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [9.10.6] - 2020-07-24
|
||||||
|
|
||||||
|
(ws) port broadcast_server sub-command to the new server API
|
||||||
|
|
||||||
## [9.10.5] - 2020-07-24
|
## [9.10.5] - 2020-07-24
|
||||||
|
|
||||||
(unittest) port most unittests to the new server API
|
(unittest) port most unittests to the new server API
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "9.10.5"
|
#define IX_WEBSOCKET_VERSION "9.10.6"
|
||||||
|
@ -20,12 +20,12 @@ namespace ix
|
|||||||
ix::WebSocketServer server(port, hostname);
|
ix::WebSocketServer server(port, hostname);
|
||||||
server.setTLSOptions(tlsOptions);
|
server.setTLSOptions(tlsOptions);
|
||||||
|
|
||||||
server.setOnConnectionCallback([&server](std::shared_ptr<WebSocket> webSocket,
|
server.setOnClientMessageCallback(
|
||||||
std::shared_ptr<ConnectionState> connectionState,
|
[&server](std::shared_ptr<ConnectionState> connectionState,
|
||||||
std::unique_ptr<ConnectionInfo> connectionInfo) {
|
ConnectionInfo& connectionInfo,
|
||||||
auto remoteIp = connectionInfo->remoteIp;
|
WebSocket& webSocket,
|
||||||
webSocket->setOnMessageCallback([webSocket, connectionState, remoteIp, &server](
|
const WebSocketMessagePtr& msg) {
|
||||||
const WebSocketMessagePtr& msg) {
|
auto remoteIp = connectionInfo.remoteIp;
|
||||||
if (msg->type == ix::WebSocketMessageType::Open)
|
if (msg->type == ix::WebSocketMessageType::Open)
|
||||||
{
|
{
|
||||||
spdlog::info("New connection");
|
spdlog::info("New connection");
|
||||||
@ -63,7 +63,7 @@ namespace ix
|
|||||||
|
|
||||||
for (auto&& client : server.getClients())
|
for (auto&& client : server.getClients())
|
||||||
{
|
{
|
||||||
if (client != webSocket)
|
if (client.get() != &webSocket)
|
||||||
{
|
{
|
||||||
client->send(msg->str, msg->binary, [](int current, int total) -> bool {
|
client->send(msg->str, msg->binary, [](int current, int total) -> bool {
|
||||||
spdlog::info("Step {} out of {}", current, total);
|
spdlog::info("Step {} out of {}", current, total);
|
||||||
@ -82,7 +82,6 @@ namespace ix
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
auto res = server.listen();
|
auto res = server.listen();
|
||||||
if (!res.first)
|
if (!res.first)
|
||||||
|
Loading…
Reference in New Issue
Block a user