ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/communicator/command_parser/msg.h
Revision: 1.3
Committed: Mon Oct 18 16:38:02 2010 UTC (15 years, 11 months ago) by sf-pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +4 -10 lines
Log Message:
support msg colours

File Contents

# User Rev Content
1 sf-pippijn 1.1 #include <json/json.h>
2    
3     void
4     command_parser::on_msg (std::istream &args)
5     {
6 sf-pippijn 1.2 if (args.peek () == '[')
7     {
8     Json::Reader reader;
9     Json::Value msg;
10     if (!reader.parse (args, msg, false))
11     throw std::runtime_error ("error parsing input: " + reader.getFormatedErrorMessages ());
12 sf-pippijn 1.1
13 sf-pippijn 1.2 assert (msg.type () == Json::arrayValue);
14     emit msg (msg[0u].asUInt (), msg[1u].asString (), msg[2u].asString ());
15     }
16     else
17     {
18 sf-pippijn 1.3 int level;
19 sf-pippijn 1.2 std::string channel;
20     std::string msg;
21    
22 sf-pippijn 1.3 args >> level >> channel;
23 sf-pippijn 1.2 while (args.peek () == ' ')
24     args.ignore ();
25 sf-pippijn 1.3 std::getline (args, msg);
26 sf-pippijn 1.2
27 sf-pippijn 1.3 emit msg (level, channel, msg);
28 sf-pippijn 1.2 }
29 sf-pippijn 1.1 }