ixwebsocketserver::broadcast server to return a boolean to know whether the server could start/listen, and use that in ws
This commit is contained in:
parent
7fee54464e
commit
88970604e3
@ -201,15 +201,15 @@ namespace ix
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
int WebSocketServer::listenAndStart()
|
bool WebSocketServer::listenAndStart()
|
||||||
{
|
{
|
||||||
auto res = listen();
|
auto res = listen();
|
||||||
if (!res.first)
|
if (!res.first)
|
||||||
{
|
{
|
||||||
return 1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
start();
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -48,7 +48,7 @@ namespace ix
|
|||||||
std::set<std::shared_ptr<WebSocket>> getClients();
|
std::set<std::shared_ptr<WebSocket>> getClients();
|
||||||
|
|
||||||
void makeBroadcastServer();
|
void makeBroadcastServer();
|
||||||
int listenAndStart();
|
bool listenAndStart();
|
||||||
|
|
||||||
const static int kDefaultHandShakeTimeoutSecs;
|
const static int kDefaultHandShakeTimeoutSecs;
|
||||||
|
|
||||||
|
10
ws/ws.cpp
10
ws/ws.cpp
@ -2768,8 +2768,14 @@ int main(int argc, char** argv)
|
|||||||
ix::WebSocketServer server(port, hostname);
|
ix::WebSocketServer server(port, hostname);
|
||||||
server.setTLSOptions(tlsOptions);
|
server.setTLSOptions(tlsOptions);
|
||||||
server.makeBroadcastServer();
|
server.makeBroadcastServer();
|
||||||
server.listenAndStart();
|
if (!server.listenAndStart())
|
||||||
server.wait();
|
{
|
||||||
|
spdlog::error("Error while starting the server");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
server.wait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("send"))
|
else if (app.got_subcommand("send"))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user