|
@@ -394,14 +394,18 @@ CmdMan::CmdRet CmdMan::cmdConnect(vector<string> args) {
|
|
|
if (args.size() < 1) {
|
|
|
retval.type = error;
|
|
|
root["error"] = "not enough arguments, at least 1 argument required";
|
|
|
- } else if (args.size() < 2) {
|
|
|
- retval.type = connect;
|
|
|
- root["address"] = args[0];
|
|
|
- root["port"] = 1234;
|
|
|
} else {
|
|
|
+ // set internal ip and port fields first
|
|
|
+ ip = args[0];
|
|
|
+ if (args.size() < 2) {
|
|
|
+ port = 1234;
|
|
|
+ } else {
|
|
|
+ port = (unsigned int)stoul(args[1]);
|
|
|
+ }
|
|
|
+ // construct json
|
|
|
retval.type = connect;
|
|
|
- root["address"] = args[0];
|
|
|
- root["port"] = (unsigned int)stoul(args[1]);
|
|
|
+ root["address"] = ip;
|
|
|
+ root["port"] = port;
|
|
|
}
|
|
|
retval.msg = root;
|
|
|
|
|
@@ -574,7 +578,7 @@ CmdMan::CmdRet CmdMan::cmdLogin(vector<string> args) {
|
|
|
} else {
|
|
|
if (currentState == loginpossible) {
|
|
|
currentState = dologin;
|
|
|
- root["user"] = args[0];
|
|
|
+ root["user"] = username = args[0];
|
|
|
root["pass"] = args[1];
|
|
|
root["login"] = true;
|
|
|
root["cancel"] = false;
|
|
@@ -605,7 +609,7 @@ CmdMan::CmdRet CmdMan::cmdSignup(vector<string> args) {
|
|
|
} else {
|
|
|
if (currentState == loginpossible) {
|
|
|
currentState = dosignup;
|
|
|
- root["user"] = args[0];
|
|
|
+ root["user"] = username = args[0];
|
|
|
root["pass"] = args[1];
|
|
|
root["login"] = false;
|
|
|
root["cancel"] = false;
|
|
@@ -718,9 +722,12 @@ CmdMan::CmdRet CmdMan::handle(Json::Value root) {
|
|
|
|
|
|
CmdMan::CmdRet CmdMan::handleStatus(Json::Value root) {
|
|
|
CmdRet retval;
|
|
|
+ Json::Value output;
|
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
retval.type = print;
|
|
|
- retval.msg = root;
|
|
|
+ output["command"] = "status";
|
|
|
+ output["response"] = username + "@" + ip + ":" + std::to_string(port) + " - Status: " + root["response"].asString();
|
|
|
+ retval.msg = output;
|
|
|
|
|
|
return retval;
|
|
|
}
|