Add client support for websocket subprotocol. Look for the new addSubProtocol method for details
This commit is contained in:
@ -71,6 +71,7 @@ int main(int argc, char** argv)
|
||||
std::string redisHosts("127.0.0.1");
|
||||
std::string redisPassword;
|
||||
std::string appsConfigPath("appsConfig.json");
|
||||
std::string subprotocol;
|
||||
ix::SocketTLSOptions tlsOptions;
|
||||
std::string ciphers;
|
||||
std::string redirectUrl;
|
||||
@ -149,6 +150,7 @@ int main(int argc, char** argv)
|
||||
connectApp->add_option("--max_wait",
|
||||
maxWaitBetweenReconnectionRetries,
|
||||
"Max Wait Time between reconnection retries");
|
||||
connectApp->add_option("--subprotocol", subprotocol, "Subprotocol");
|
||||
addTLSOptions(connectApp);
|
||||
|
||||
CLI::App* chatApp = app.add_subcommand("chat", "Group chat");
|
||||
@ -329,7 +331,8 @@ int main(int argc, char** argv)
|
||||
disablePerMessageDeflate,
|
||||
binaryMode,
|
||||
maxWaitBetweenReconnectionRetries,
|
||||
tlsOptions);
|
||||
tlsOptions,
|
||||
subprotocol);
|
||||
}
|
||||
else if (app.got_subcommand("chat"))
|
||||
{
|
||||
|
3
ws/ws.h
3
ws/ws.h
@ -45,7 +45,8 @@ namespace ix
|
||||
bool disablePerMessageDeflate,
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
const ix::SocketTLSOptions& tlsOptions,
|
||||
const std::string& subprotocol);
|
||||
|
||||
int ws_receive_main(const std::string& url,
|
||||
bool enablePerMessageDeflate,
|
||||
|
@ -23,7 +23,8 @@ namespace ix
|
||||
bool disablePerMessageDeflate,
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
const ix::SocketTLSOptions& tlsOptions,
|
||||
const std::string& subprotocol);
|
||||
|
||||
void subscribe(const std::string& channel);
|
||||
void start();
|
||||
@ -48,7 +49,8 @@ namespace ix
|
||||
bool disablePerMessageDeflate,
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
const ix::SocketTLSOptions& tlsOptions,
|
||||
const std::string& subprotocol)
|
||||
: _url(url)
|
||||
, _disablePerMessageDeflate(disablePerMessageDeflate)
|
||||
, _binaryMode(binaryMode)
|
||||
@ -61,6 +63,11 @@ namespace ix
|
||||
_webSocket.setTLSOptions(tlsOptions);
|
||||
|
||||
_headers = parseHeaders(headers);
|
||||
|
||||
if (!subprotocol.empty())
|
||||
{
|
||||
_webSocket.addSubProtocol(subprotocol);
|
||||
}
|
||||
}
|
||||
|
||||
void WebSocketConnect::log(const std::string& msg)
|
||||
@ -191,7 +198,8 @@ namespace ix
|
||||
bool disablePerMessageDeflate,
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
const ix::SocketTLSOptions& tlsOptions,
|
||||
const std::string& subprotocol)
|
||||
{
|
||||
std::cout << "Type Ctrl-D to exit prompt..." << std::endl;
|
||||
WebSocketConnect webSocketChat(url,
|
||||
@ -200,7 +208,8 @@ namespace ix
|
||||
disablePerMessageDeflate,
|
||||
binaryMode,
|
||||
maxWaitBetweenReconnectionRetries,
|
||||
tlsOptions);
|
||||
tlsOptions,
|
||||
subprotocol);
|
||||
webSocketChat.start();
|
||||
|
||||
while (true)
|
||||
|
Reference in New Issue
Block a user