small protocol change
This commit is contained in:
parent
40d292c4ac
commit
2e0b16e90b
2 changed files with 9 additions and 12 deletions
|
@ -111,20 +111,19 @@ void Client::readLine()
|
|||
} else
|
||||
emit gameEvent(event);
|
||||
} else if (prefix == "resp") {
|
||||
if (values.size() != 2) {
|
||||
// XXX
|
||||
}
|
||||
bool ok;
|
||||
int msgid = values.takeFirst().toInt(&ok);
|
||||
if (!ok) {
|
||||
// XXX
|
||||
}
|
||||
|
||||
if (values.empty()) {
|
||||
// XXX
|
||||
}
|
||||
|
||||
ServerResponse resp;
|
||||
if (values[0] == "ok")
|
||||
resp = RespOk;
|
||||
else if (values[1] == "password")
|
||||
else if (values[0] == "password")
|
||||
resp = RespPassword;
|
||||
else
|
||||
resp = RespErr;
|
||||
|
|
|
@ -6,20 +6,18 @@ bool ReturnMessage::send(ReturnCode code)
|
|||
ServerSocket *s = qobject_cast<ServerSocket *>(parent());
|
||||
if (!s)
|
||||
return false;
|
||||
bool success = (code == ReturnOk);
|
||||
QString returnCodeString;
|
||||
switch (code) {
|
||||
case ReturnNothing: return true;
|
||||
case ReturnOk: break;
|
||||
case ReturnOk: returnCodeString = "ok"; break;
|
||||
case ReturnLoginNeeded: returnCodeString = "login_needed"; break;
|
||||
case ReturnSyntaxError: returnCodeString = "syntax"; break;
|
||||
case ReturnContextError: returnCodeString = "context"; break;
|
||||
case ReturnPasswordWrong: returnCodeString = "password"; break;
|
||||
}
|
||||
s->msg(QString("resp|%1|%2|%3").arg(msg_id)
|
||||
.arg(success ? "ok" : "err")
|
||||
s->msg(QString("resp|%1|%2").arg(msg_id)
|
||||
.arg(returnCodeString));
|
||||
return success;
|
||||
return (code == ReturnOk);
|
||||
}
|
||||
|
||||
bool ReturnMessage::sendList(const QStringList &args)
|
||||
|
|
Loading…
Reference in a new issue