(cobra connection) retrieve cobra server connection id from the cobra handshake message and display it in ws clients, metrics publisher and bots

This commit is contained in:
Benjamin Sergeant 2020-09-22 09:30:19 -07:00
parent 62d220f49a
commit 97cc543e53
8 changed files with 38 additions and 7 deletions

View File

@ -2,6 +2,10 @@
All changes to this project will be documented in this file. All changes to this project will be documented in this file.
## [10.4.4] - 2020-09-22
(cobra connection) retrieve cobra server connection id from the cobra handshake message and display it in ws clients, metrics publisher and bots
## [10.4.3] - 2020-09-22 ## [10.4.3] - 2020-09-22
(cobra 2 cobra) specify as an HTTP header which channel we will republish to (cobra 2 cobra) specify as an HTTP header which channel we will republish to

View File

@ -170,7 +170,11 @@ namespace ix
} }
else if (event->type == ix::CobraEventType::Closed) else if (event->type == ix::CobraEventType::Closed)
{ {
CoreLogger::info("Subscriber closed: {}" + event->errMsg); CoreLogger::info("Subscriber closed: " + event->errMsg);
}
else if (event->type == ix::CobraEventType::Handshake)
{
CoreLogger::info("Subscriber: Cobra handshake connection id: " + event->connectionId);
} }
else if (event->type == ix::CobraEventType::Authenticated) else if (event->type == ix::CobraEventType::Authenticated)
{ {

View File

@ -91,13 +91,14 @@ namespace ix
const std::string& errorMsg, const std::string& errorMsg,
const WebSocketHttpHeaders& headers, const WebSocketHttpHeaders& headers,
const std::string& subscriptionId, const std::string& subscriptionId,
CobraConnection::MsgId msgId) CobraConnection::MsgId msgId,
const std::string& connectionId)
{ {
std::lock_guard<std::mutex> lock(_eventCallbackMutex); std::lock_guard<std::mutex> lock(_eventCallbackMutex);
if (_eventCallback) if (_eventCallback)
{ {
_eventCallback( _eventCallback(
std::make_unique<CobraEvent>(eventType, errorMsg, headers, subscriptionId, msgId)); std::make_unique<CobraEvent>(eventType, errorMsg, headers, subscriptionId, msgId, connectionId));
} }
} }
@ -352,6 +353,18 @@ namespace ix
if (!nonce.isString()) return false; if (!nonce.isString()) return false;
if (!data.isMember("connection_id")) return false;
Json::Value connectionId = data["connection_id"];
if (!connectionId.isString()) return false;
invokeEventCallback(ix::CobraEventType::Handshake,
std::string(),
WebSocketHttpHeaders(),
std::string(),
0,
connectionId.asString());
return sendAuthMessage(nonce.asString()); return sendAuthMessage(nonce.asString());
} }

View File

@ -158,7 +158,9 @@ namespace ix
const std::string& errorMsg = std::string(), const std::string& errorMsg = std::string(),
const WebSocketHttpHeaders& headers = WebSocketHttpHeaders(), const WebSocketHttpHeaders& headers = WebSocketHttpHeaders(),
const std::string& subscriptionId = std::string(), const std::string& subscriptionId = std::string(),
uint64_t msgId = std::numeric_limits<uint64_t>::max()); uint64_t msgId = std::numeric_limits<uint64_t>::max(),
const std::string& connectionId = std::string());
void invokeErrorCallback(const std::string& errorMsg, const std::string& serializedPdu); void invokeErrorCallback(const std::string& errorMsg, const std::string& serializedPdu);
/// Tells whether the internal queue is empty or not /// Tells whether the internal queue is empty or not

View File

@ -21,17 +21,20 @@ namespace ix
const ix::WebSocketHttpHeaders& headers; const ix::WebSocketHttpHeaders& headers;
const std::string& subscriptionId; const std::string& subscriptionId;
uint64_t msgId; // CobraConnection::MsgId uint64_t msgId; // CobraConnection::MsgId
const std::string& connectionId;
CobraEvent(ix::CobraEventType t, CobraEvent(ix::CobraEventType t,
const std::string& e, const std::string& e,
const ix::WebSocketHttpHeaders& h, const ix::WebSocketHttpHeaders& h,
const std::string& s, const std::string& s,
uint64_t m) uint64_t m,
const std::string& c)
: type(t) : type(t)
, errMsg(e) , errMsg(e)
, headers(h) , headers(h)
, subscriptionId(s) , subscriptionId(s)
, msgId(m) , msgId(m)
, connectionId(c)
{ {
; ;
} }

View File

@ -20,6 +20,7 @@ namespace ix
Pong = 7, Pong = 7,
HandshakeError = 8, HandshakeError = 8,
AuthenticationError = 9, AuthenticationError = 9,
SubscriptionError = 10 SubscriptionError = 10,
Handshake = 11
}; };
} }

View File

@ -35,6 +35,10 @@ namespace ix
ss << it.first << ": " << it.second << std::endl; ss << it.first << ": " << it.second << std::endl;
} }
} }
else if (event->type == ix::CobraEventType::Handshake)
{
ss << "Cobra handshake connection id: " << event->connectionId;
}
else if (event->type == ix::CobraEventType::Authenticated) else if (event->type == ix::CobraEventType::Authenticated)
{ {
ss << "Authenticated"; ss << "Authenticated";

View File

@ -6,4 +6,4 @@
#pragma once #pragma once
#define IX_WEBSOCKET_VERSION "10.4.3" #define IX_WEBSOCKET_VERSION "10.4.4"