Created
September 20, 2012 14:40
-
-
Save barneywilliams/3756323 to your computer and use it in GitHub Desktop.
JSONSocket - Qt JSON parsing and validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QString Client::ProcessCommand(QScriptValue req) | |
{ | |
QScriptValue cmd = req.property("command"); | |
QString response; | |
// Basic sanity check | |
if (!cmd.isValid()) | |
{ | |
response = CommandErrorResponse("invalid", "No command specified"); | |
} | |
// Process greeting | |
else if (cmd.toString() == "greeting") | |
{ | |
QScriptValue message = req.property("message"); | |
if (!message.isValid()) | |
{ | |
response = CommandErrorResponse("greeting", "No message specified"); | |
} | |
else | |
{ | |
response = CommandResponse("greeting", "Hello server. Hope things are well!"); | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment