Basic work on subscriptions

This commit is contained in:
KimLS
2017-01-13 21:52:08 -08:00
parent f24770489e
commit 1cafd6831d
12 changed files with 196 additions and 42 deletions
+21
View File
@@ -105,6 +105,21 @@ void WebInterface::SendError(const std::string &message, const std::string &id)
Send(error);
}
void WebInterface::SendEvent(const Json::Value &value)
{
try {
std::stringstream ss;
ss << value;
EQ::Net::DynamicPacket p;
p.PutString(0, ss.str());
m_connection->Send(ServerOP_WebInterfaceEvent, p);
}
catch (std::exception) {
//Log error
}
}
void WebInterface::AddCall(const std::string &method, WebInterfaceCall call)
{
m_calls.insert(std::make_pair(method, call));
@@ -149,6 +164,12 @@ void WebInterfaceList::SendResponse(const std::string &uuid, std::string &id, co
}
}
void WebInterfaceList::SendEvent(const Json::Value &value) {
for (auto &i : m_interfaces) {
i.second->SendEvent(value);
}
}
void WebInterfaceList::SendError(const std::string &uuid, const std::string &message) {
auto iter = m_interfaces.find(uuid);
if (iter != m_interfaces.end()) {