ws broacast_server / can set serving hostname
This commit is contained in:
parent
f2778c0729
commit
ad9c8318a7
@ -19,4 +19,4 @@ WORKDIR ws
|
|||||||
RUN ["sh", "docker_build.sh"]
|
RUN ["sh", "docker_build.sh"]
|
||||||
|
|
||||||
EXPOSE 8765
|
EXPOSE 8765
|
||||||
CMD ["/ws/ws", "transfer", "8765"]
|
CMD ["/ws/ws", "transfer", "--port", "8765", "--hostname", "0.0.0.0"]
|
||||||
|
@ -13,6 +13,7 @@ g++ --std=c++14 \
|
|||||||
../ixwebsocket/IXSocket.cpp \
|
../ixwebsocket/IXSocket.cpp \
|
||||||
../ixwebsocket/IXSocketServer.cpp \
|
../ixwebsocket/IXSocketServer.cpp \
|
||||||
../ixwebsocket/IXSocketConnect.cpp \
|
../ixwebsocket/IXSocketConnect.cpp \
|
||||||
|
../ixwebsocket/IXSocketFactory.cpp \
|
||||||
../ixwebsocket/IXDNSLookup.cpp \
|
../ixwebsocket/IXDNSLookup.cpp \
|
||||||
../ixwebsocket/IXCancellationRequest.cpp \
|
../ixwebsocket/IXCancellationRequest.cpp \
|
||||||
../ixwebsocket/IXWebSocket.cpp \
|
../ixwebsocket/IXWebSocket.cpp \
|
||||||
@ -22,12 +23,16 @@ g++ --std=c++14 \
|
|||||||
../ixwebsocket/IXWebSocketPerMessageDeflate.cpp \
|
../ixwebsocket/IXWebSocketPerMessageDeflate.cpp \
|
||||||
../ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp \
|
../ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp \
|
||||||
../ixwebsocket/IXWebSocketPerMessageDeflateOptions.cpp \
|
../ixwebsocket/IXWebSocketPerMessageDeflateOptions.cpp \
|
||||||
|
../ixwebsocket/IXWebSocketHttpHeaders.cpp \
|
||||||
|
../ixwebsocket/IXHttpClient.cpp \
|
||||||
|
../ixwebsocket/IXUrlParser.cpp \
|
||||||
../ixwebsocket/IXSocketOpenSSL.cpp \
|
../ixwebsocket/IXSocketOpenSSL.cpp \
|
||||||
../ixwebsocket/linux/IXSetThreadName_linux.cpp \
|
../ixwebsocket/linux/IXSetThreadName_linux.cpp \
|
||||||
../third_party/jsoncpp/jsoncpp.cpp \
|
../third_party/msgpack11/msgpack11.cpp \
|
||||||
ixcrypto/IXBase64.cpp \
|
ixcrypto/IXBase64.cpp \
|
||||||
ixcrypto/IXHash.cpp \
|
ixcrypto/IXHash.cpp \
|
||||||
ixcrypto/IXUuid.cpp \
|
ixcrypto/IXUuid.cpp \
|
||||||
|
ws_http_client.cpp \
|
||||||
ws_ping_pong.cpp \
|
ws_ping_pong.cpp \
|
||||||
ws_broadcast_server.cpp \
|
ws_broadcast_server.cpp \
|
||||||
ws_echo_server.cpp \
|
ws_echo_server.cpp \
|
||||||
|
@ -31,6 +31,7 @@ int main(int argc, char** argv)
|
|||||||
std::string data;
|
std::string data;
|
||||||
std::string headers;
|
std::string headers;
|
||||||
std::string output;
|
std::string output;
|
||||||
|
std::string hostname;
|
||||||
bool headersOnly = false;
|
bool headersOnly = false;
|
||||||
bool followRedirects = false;
|
bool followRedirects = false;
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
@ -63,6 +64,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
CLI::App* broadcastServerApp = app.add_subcommand("broadcast_server", "Broadcasting server");
|
CLI::App* broadcastServerApp = app.add_subcommand("broadcast_server", "Broadcasting server");
|
||||||
broadcastServerApp->add_option("--port", port, "Connection url");
|
broadcastServerApp->add_option("--port", port, "Connection url");
|
||||||
|
broadcastServerApp->add_option("--hostname", hostname, "Hostname");
|
||||||
|
|
||||||
CLI::App* pingPongApp = app.add_subcommand("ping", "Ping pong");
|
CLI::App* pingPongApp = app.add_subcommand("ping", "Ping pong");
|
||||||
pingPongApp->add_option("url", url, "Connection url")->required();
|
pingPongApp->add_option("url", url, "Connection url")->required();
|
||||||
@ -113,7 +115,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
else if (app.got_subcommand("broadcast_server"))
|
else if (app.got_subcommand("broadcast_server"))
|
||||||
{
|
{
|
||||||
return ix::ws_broadcast_server_main(port);
|
return ix::ws_broadcast_server_main(port, hostname);
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("ping"))
|
else if (app.got_subcommand("ping"))
|
||||||
{
|
{
|
||||||
|
2
ws/ws.h
2
ws/ws.h
@ -26,7 +26,7 @@ namespace ix
|
|||||||
|
|
||||||
int ws_echo_server_main(int port);
|
int ws_echo_server_main(int port);
|
||||||
|
|
||||||
int ws_broadcast_server_main(int port);
|
int ws_broadcast_server_main(int port, const std::string& hostname);
|
||||||
|
|
||||||
int ws_chat_main(const std::string& url,
|
int ws_chat_main(const std::string& url,
|
||||||
const std::string& user);
|
const std::string& user);
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
int ws_broadcast_server_main(int port)
|
int ws_broadcast_server_main(int port, const std::string& hostname)
|
||||||
{
|
{
|
||||||
std::cout << "Listening on port " << port << std::endl;
|
std::cout << "Listening on " << hostname << ":" << port << std::endl;
|
||||||
|
|
||||||
ix::WebSocketServer server(port);
|
ix::WebSocketServer server(port, hostname);
|
||||||
|
|
||||||
server.setOnConnectionCallback(
|
server.setOnConnectionCallback(
|
||||||
[&server](std::shared_ptr<ix::WebSocket> webSocket)
|
[&server](std::shared_ptr<ix::WebSocket> webSocket)
|
||||||
|
Loading…
Reference in New Issue
Block a user