clang-format
This commit is contained in:
parent
9b8cfa0a37
commit
ccfd196863
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "IXWebSocketHttpHeaders.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "IXWebSocketHttpHeaders.h"
|
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
|
@ -222,7 +222,8 @@ namespace ix
|
|||||||
{
|
{
|
||||||
_pongReceived = false;
|
_pongReceived = false;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << kPingMessage << "::" << _pingIntervalSecs << "s" << "::" << _pingCount++;
|
ss << kPingMessage << "::" << _pingIntervalSecs << "s"
|
||||||
|
<< "::" << _pingCount++;
|
||||||
return sendPing(ss.str());
|
return sendPing(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,8 +180,7 @@ namespace
|
|||||||
_conn.configure(_cobraConfig);
|
_conn.configure(_cobraConfig);
|
||||||
_conn.connect();
|
_conn.connect();
|
||||||
|
|
||||||
_conn.setEventCallback([this, channel](const CobraEventPtr& event)
|
_conn.setEventCallback([this, channel](const CobraEventPtr& event) {
|
||||||
{
|
|
||||||
if (event->type == ix::CobraEventType::Open)
|
if (event->type == ix::CobraEventType::Open)
|
||||||
{
|
{
|
||||||
log("Subscriber connected: " + _user);
|
log("Subscriber connected: " + _user);
|
||||||
|
@ -54,8 +54,7 @@ namespace
|
|||||||
conn.configure(config);
|
conn.configure(config);
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
conn.setEventCallback([&conn, &channel](const CobraEventPtr& event)
|
conn.setEventCallback([&conn, &channel](const CobraEventPtr& event) {
|
||||||
{
|
|
||||||
if (event->type == ix::CobraEventType::Open)
|
if (event->type == ix::CobraEventType::Open)
|
||||||
{
|
{
|
||||||
TLogger() << "Subscriber connected:";
|
TLogger() << "Subscriber connected:";
|
||||||
|
@ -106,8 +106,7 @@ namespace ix
|
|||||||
&msgPerSeconds,
|
&msgPerSeconds,
|
||||||
&conditionVariableMutex,
|
&conditionVariableMutex,
|
||||||
&condition,
|
&condition,
|
||||||
&queue](const CobraEventPtr& event)
|
&queue](const CobraEventPtr& event) {
|
||||||
{
|
|
||||||
if (event->type == ix::CobraEventType::Open)
|
if (event->type == ix::CobraEventType::Open)
|
||||||
{
|
{
|
||||||
spdlog::info("Subscriber connected");
|
spdlog::info("Subscriber connected");
|
||||||
|
@ -38,62 +38,62 @@ namespace ix
|
|||||||
std::atomic<bool> authenticated(false);
|
std::atomic<bool> authenticated(false);
|
||||||
std::atomic<bool> messageAcked(false);
|
std::atomic<bool> messageAcked(false);
|
||||||
|
|
||||||
conn.setEventCallback([&conn, &channel, &data, &authenticated, &messageAcked](const CobraEventPtr& event)
|
conn.setEventCallback(
|
||||||
{
|
[&conn, &channel, &data, &authenticated, &messageAcked](const CobraEventPtr& event) {
|
||||||
if (event->type == ix::CobraEventType::Open)
|
if (event->type == ix::CobraEventType::Open)
|
||||||
{
|
|
||||||
spdlog::info("Publisher connected");
|
|
||||||
|
|
||||||
for (auto&& it : event->headers)
|
|
||||||
{
|
{
|
||||||
spdlog::info("{}: {}", it.first, it.second);
|
spdlog::info("Publisher connected");
|
||||||
|
|
||||||
|
for (auto&& it : event->headers)
|
||||||
|
{
|
||||||
|
spdlog::info("{}: {}", it.first, it.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (event->type == ix::CobraEventType::Closed)
|
||||||
else if (event->type == ix::CobraEventType::Closed)
|
{
|
||||||
{
|
spdlog::info("Subscriber closed: {}", event->errMsg);
|
||||||
spdlog::info("Subscriber closed: {}", event->errMsg);
|
}
|
||||||
}
|
else if (event->type == ix::CobraEventType::Authenticated)
|
||||||
else if (event->type == ix::CobraEventType::Authenticated)
|
{
|
||||||
{
|
spdlog::info("Publisher authenticated");
|
||||||
spdlog::info("Publisher authenticated");
|
authenticated = true;
|
||||||
authenticated = true;
|
|
||||||
|
|
||||||
Json::Value channels;
|
Json::Value channels;
|
||||||
channels[0] = channel;
|
channels[0] = channel;
|
||||||
auto msgId = conn.publish(channels, data);
|
auto msgId = conn.publish(channels, data);
|
||||||
|
|
||||||
spdlog::info("Published msg {}", msgId);
|
spdlog::info("Published msg {}", msgId);
|
||||||
}
|
}
|
||||||
else if (event->type == ix::CobraEventType::Subscribed)
|
else if (event->type == ix::CobraEventType::Subscribed)
|
||||||
{
|
{
|
||||||
spdlog::info("Publisher: subscribed to channel {}", event->subscriptionId);
|
spdlog::info("Publisher: subscribed to channel {}", event->subscriptionId);
|
||||||
}
|
}
|
||||||
else if (event->type == ix::CobraEventType::UnSubscribed)
|
else if (event->type == ix::CobraEventType::UnSubscribed)
|
||||||
{
|
{
|
||||||
spdlog::info("Publisher: unsubscribed from channel {}", event->subscriptionId);
|
spdlog::info("Publisher: unsubscribed from channel {}", event->subscriptionId);
|
||||||
}
|
}
|
||||||
else if (event->type == ix::CobraEventType::Error)
|
else if (event->type == ix::CobraEventType::Error)
|
||||||
{
|
{
|
||||||
spdlog::error("Publisher: error {}", event->errMsg);
|
spdlog::error("Publisher: error {}", event->errMsg);
|
||||||
}
|
}
|
||||||
else if (event->type == ix::CobraEventType::Published)
|
else if (event->type == ix::CobraEventType::Published)
|
||||||
{
|
{
|
||||||
spdlog::info("Published message id {} acked", event->msgId);
|
spdlog::info("Published message id {} acked", event->msgId);
|
||||||
messageAcked = true;
|
messageAcked = true;
|
||||||
}
|
}
|
||||||
else if (event->type == ix::CobraEventType::Pong)
|
else if (event->type == ix::CobraEventType::Pong)
|
||||||
{
|
{
|
||||||
spdlog::info("Received websocket pong");
|
spdlog::info("Received websocket pong");
|
||||||
}
|
}
|
||||||
else if (event->type == ix::CobraEventType::HandshakeError)
|
else if (event->type == ix::CobraEventType::HandshakeError)
|
||||||
{
|
{
|
||||||
spdlog::error("Subscriber: Handshake error: {}", event->errMsg);
|
spdlog::error("Subscriber: Handshake error: {}", event->errMsg);
|
||||||
}
|
}
|
||||||
else if (event->type == ix::CobraEventType::AuthenticationError)
|
else if (event->type == ix::CobraEventType::AuthenticationError)
|
||||||
{
|
{
|
||||||
spdlog::error("Subscriber: Authentication error: {}", event->errMsg);
|
spdlog::error("Subscriber: Authentication error: {}", event->errMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
|
@ -106,8 +106,7 @@ namespace ix
|
|||||||
&msgPerSeconds,
|
&msgPerSeconds,
|
||||||
&quiet,
|
&quiet,
|
||||||
&fluentd,
|
&fluentd,
|
||||||
&fatalCobraError](const CobraEventPtr& event)
|
&fatalCobraError](const CobraEventPtr& event) {
|
||||||
{
|
|
||||||
if (event->type == ix::CobraEventType::Open)
|
if (event->type == ix::CobraEventType::Open)
|
||||||
{
|
{
|
||||||
spdlog::info("Subscriber connected");
|
spdlog::info("Subscriber connected");
|
||||||
|
Loading…
Reference in New Issue
Block a user