compiler warning fixes

This commit is contained in:
Benjamin Sergeant 2020-07-28 21:46:26 -07:00
parent dc77d62a5d
commit e85f975ab0
6 changed files with 45 additions and 45 deletions

View File

@ -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.
## [10.0.3] - 2020-07-28
compiler warning fixes
## [10.0.2] - 2020-07-28 ## [10.0.2] - 2020-07-28
(ixcobra) CobraConnection: unsubscribe from all subscriptions when disconnecting (ixcobra) CobraConnection: unsubscribe from all subscriptions when disconnecting

View File

@ -19,7 +19,6 @@ namespace snake
{ {
void handleError(const std::string& action, void handleError(const std::string& action,
ix::WebSocket& ws, ix::WebSocket& ws,
const nlohmann::json& pdu,
uint64_t pduId, uint64_t pduId,
const std::string& errMsg) const std::string& errMsg)
{ {
@ -116,7 +115,7 @@ namespace snake
{ {
std::stringstream ss; std::stringstream ss;
ss << "Missing channels or channel field in publish data"; ss << "Missing channels or channel field in publish data";
handleError("rtm/publish", ws, pdu, pduId, ss.str()); handleError("rtm/publish", ws, pduId, ss.str());
return; return;
} }
@ -136,7 +135,7 @@ namespace snake
{ {
std::stringstream ss; std::stringstream ss;
ss << "Cannot publish to redis host " << errMsg; ss << "Cannot publish to redis host " << errMsg;
handleError("rtm/publish", ws, pdu, pduId, ss.str()); handleError("rtm/publish", ws, pduId, ss.str());
return; return;
} }
} }
@ -175,7 +174,7 @@ namespace snake
{ {
std::stringstream ss; std::stringstream ss;
ss << "Cannot connect to redis host " << hostname << ":" << port; ss << "Cannot connect to redis host " << hostname << ":" << port;
handleError("rtm/subscribe", ws, pdu, pduId, ss.str()); handleError("rtm/subscribe", ws, pduId, ss.str());
return; return;
} }
@ -187,7 +186,7 @@ namespace snake
{ {
std::stringstream ss; std::stringstream ss;
ss << "Cannot authenticated to redis"; ss << "Cannot authenticated to redis";
handleError("rtm/subscribe", ws, pdu, pduId, ss.str()); handleError("rtm/subscribe", ws, pduId, ss.str());
return; return;
} }
} }
@ -236,7 +235,7 @@ namespace snake
ix::CoreLogger::log(ss.str().c_str()); ix::CoreLogger::log(ss.str().c_str());
} }
auto subscription = [&redisClient, state, &ws, &pdu, pduId] auto subscription = [&redisClient, state, &ws, pduId]
{ {
if (!redisClient.subscribe(state->appChannel, if (!redisClient.subscribe(state->appChannel,
state->onRedisSubscribeResponseCallback, state->onRedisSubscribeResponseCallback,
@ -244,7 +243,7 @@ namespace snake
{ {
std::stringstream ss; std::stringstream ss;
ss << "Error subscribing to channel " << state->appChannel; ss << "Error subscribing to channel " << state->appChannel;
handleError("rtm/subscribe", ws, pdu, pduId, ss.str()); handleError("rtm/subscribe", ws, pduId, ss.str());
return; return;
} }
}; };

View File

@ -43,7 +43,7 @@ namespace ix
const std::string& hostname, const std::string& hostname,
const ix::SocketTLSOptions& tlsOptions, const ix::SocketTLSOptions& tlsOptions,
const std::string& remoteUrl, const std::string& remoteUrl,
bool verbose) bool /*verbose*/)
{ {
ix::WebSocketServer server(port, hostname); ix::WebSocketServer server(port, hostname);
server.setTLSOptions(tlsOptions); server.setTLSOptions(tlsOptions);
@ -53,16 +53,15 @@ namespace ix
}; };
server.setConnectionStateFactory(factory); server.setConnectionStateFactory(factory);
server.setOnConnectionCallback([remoteUrl, server.setOnConnectionCallback([remoteUrl](std::weak_ptr<ix::WebSocket> webSocket,
verbose](std::weak_ptr<ix::WebSocket> webSocket, std::shared_ptr<ConnectionState> connectionState,
std::shared_ptr<ConnectionState> connectionState, std::unique_ptr<ConnectionInfo> connectionInfo) {
std::unique_ptr<ConnectionInfo> connectionInfo) {
auto state = std::dynamic_pointer_cast<ProxyConnectionState>(connectionState); auto state = std::dynamic_pointer_cast<ProxyConnectionState>(connectionState);
auto remoteIp = connectionInfo->remoteIp; auto remoteIp = connectionInfo->remoteIp;
// Server connection // Server connection
state->webSocket().setOnMessageCallback( state->webSocket().setOnMessageCallback(
[webSocket, state, remoteIp, verbose](const WebSocketMessagePtr& msg) { [webSocket, state, remoteIp](const WebSocketMessagePtr& msg) {
if (msg->type == ix::WebSocketMessageType::Close) if (msg->type == ix::WebSocketMessageType::Close)
{ {
state->setTerminated(); state->setTerminated();
@ -81,33 +80,32 @@ namespace ix
auto ws = webSocket.lock(); auto ws = webSocket.lock();
if (ws) if (ws)
{ {
ws->setOnMessageCallback( ws->setOnMessageCallback([state, remoteUrl](const WebSocketMessagePtr& msg) {
[state, remoteUrl, verbose](const WebSocketMessagePtr& msg) { if (msg->type == ix::WebSocketMessageType::Open)
if (msg->type == ix::WebSocketMessageType::Open) {
{ // Connect to the 'real' server
// Connect to the 'real' server std::string url(remoteUrl);
std::string url(remoteUrl); url += msg->openInfo.uri;
url += msg->openInfo.uri; state->webSocket().setUrl(url);
state->webSocket().setUrl(url); state->webSocket().disableAutomaticReconnection();
state->webSocket().disableAutomaticReconnection(); state->webSocket().start();
state->webSocket().start();
// we should sleep here for a bit until we've established the // we should sleep here for a bit until we've established the
// connection with the remote server // connection with the remote server
while (state->webSocket().getReadyState() != ReadyState::Open) while (state->webSocket().getReadyState() != ReadyState::Open)
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
else if (msg->type == ix::WebSocketMessageType::Close)
{ {
state->webSocket().close(msg->closeInfo.code, msg->closeInfo.reason); std::this_thread::sleep_for(std::chrono::milliseconds(10));
} }
else if (msg->type == ix::WebSocketMessageType::Message) }
{ else if (msg->type == ix::WebSocketMessageType::Close)
state->webSocket().send(msg->str, msg->binary); {
} state->webSocket().close(msg->closeInfo.code, msg->closeInfo.reason);
}); }
else if (msg->type == ix::WebSocketMessageType::Message)
{
state->webSocket().send(msg->str, msg->binary);
}
});
} }
}); });

View File

@ -6,4 +6,4 @@
#pragma once #pragma once
#define IX_WEBSOCKET_VERSION "10.0.2" #define IX_WEBSOCKET_VERSION "10.0.3"

View File

@ -85,7 +85,7 @@ namespace ix
bool startWebSocketEchoServer(ix::WebSocketServer& server) bool startWebSocketEchoServer(ix::WebSocketServer& server)
{ {
server.setOnClientMessageCallback( server.setOnClientMessageCallback(
[&server](std::shared_ptr<ConnectionState> connectionState, [&server](std::shared_ptr<ConnectionState> /*connectionState*/,
ConnectionInfo& connectionInfo, ConnectionInfo& connectionInfo,
WebSocket& webSocket, WebSocket& webSocket,
const ix::WebSocketMessagePtr& msg) { const ix::WebSocketMessagePtr& msg) {

View File

@ -169,12 +169,11 @@ namespace
{ {
// A dev/null server // A dev/null server
server.setOnClientMessageCallback( server.setOnClientMessageCallback(
[&receivedCloseCode, &receivedCloseReason, &receivedCloseRemote, &mutexWrite [&receivedCloseCode, &receivedCloseReason, &receivedCloseRemote, &mutexWrite](
std::shared_ptr<ConnectionState> connectionState,
](std::shared_ptr<ConnectionState> connectionState, ConnectionInfo& connectionInfo,
ConnectionInfo& connectionInfo, WebSocket& /*webSocket*/,
WebSocket& webSocket, const ix::WebSocketMessagePtr& msg) {
const ix::WebSocketMessagePtr& msg) {
auto remoteIp = connectionInfo.remoteIp; auto remoteIp = connectionInfo.remoteIp;
if (msg->type == ix::WebSocketMessageType::Open) if (msg->type == ix::WebSocketMessageType::Open)
{ {