#define MS_CLASS "Channel::Notifier"
#include "Channel/ChannelNotifier.hpp"
#include "Logger.hpp"
namespace Channel
{
thread_local Channel::ChannelSocket* ChannelNotifier::channel{ nullptr };
void ChannelNotifier::ClassInit(Channel::ChannelSocket* channel)
{
MS_TRACE();
ChannelNotifier::channel = channel;
}
void ChannelNotifier::Emit(const std::string& targetId, const char* event)
{
MS_TRACE();
MS_ASSERT(ChannelNotifier::channel, "channel unset");
json jsonNotification = json::object();
jsonNotification["targetId"] = targetId;
jsonNotification["event"] = event;
ChannelNotifier::channel->Send(jsonNotification);
}
void ChannelNotifier::Emit(const std::string& targetId, const char* event, json& data)
{
MS_TRACE();
MS_ASSERT(ChannelNotifier::channel, "channel unset");
json jsonNotification = json::object();
jsonNotification["targetId"] = targetId;
jsonNotification["event"] = event;
jsonNotification["data"] = data;
ChannelNotifier::channel->Send(jsonNotification);
}
}