text
stringlengths
0
2.2M
{
return Address(value("to", ""));
}
Address Message::from() const
{
return Address(value("from", ""));
}
int Message::status() const
{
return find("status") != end() ? (*this)["status"].get<int>() : -1;
}
bool Message::isRequest() const
{
return status() == -1;
}
json::value& Message::notes()
{
return (*this)["notes"];
}
json::value Message::data(const std::string& name) const
{
return (*this)["data"][name];
}
json::value& Message::data(const std::string& name)
{
return (*this)["data"][name];
}
void Message::setType(const std::string& type)
{
(*this)["type"] = type;
}
void Message::setTo(const Peer& to)
{
(*this)["to"] = to.address().toString();
}
void Message::setTo(const Address& to)
{
(*this)["to"] = to.toString();
}
void Message::setTo(const std::string& to)
{
(*this)["to"] = to;
}
void Message::setFrom(const Peer& from)
{
(*this)["from"] = from.address().toString();
}
void Message::setFrom(const Address& from)
{
assert(is_object());
(*this)["from"] = from.toString();
}
void Message::setFrom(const std::string& from)
{
(*this)["from"] = from;
}
void Message::setStatus(int code)
{
assert(code > 100 && code < 505);
(*this)["status"] = code;
}
void Message::setNote(const std::string& type, const std::string& text)
{
clearNotes();
addNote(type, text);
}
void Message::addNote(const std::string& type, const std::string& text)
{
assert(type == "info" || type == "warn" || type == "error");