#include void command_parser::on_msg (std::istream &args) { if (args.peek () == '[') { Json::Reader reader; Json::Value msg; if (!reader.parse (args, msg, false)) throw std::runtime_error ("error parsing input: " + reader.getFormatedErrorMessages ()); assert (msg.type () == Json::arrayValue); emit msg (msg[0u].asUInt (), msg[1u].asString (), msg[2u].asString ()); } else { int n; std::string channel; std::string msg; args >> n >> channel; while (args.peek () == ' ') args.ignore (); std::getline (args, channel); if (msg.empty ()) { msg = channel; channel = "log"; } emit msg (n, channel, msg); } }