本文整理汇总了C++中ConnectionPtr::sendDebugReply方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::sendDebugReply方法的具体用法?C++ ConnectionPtr::sendDebugReply怎么用?C++ ConnectionPtr::sendDebugReply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionPtr
的用法示例。
在下文中一共展示了ConnectionPtr::sendDebugReply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DebugCommand
FReturnCode NativeCommand::DebugCommand(ConnectionPtr& con, string& payload) {
if (con->admin != true)
return FERR_NOT_ADMIN;
json_t* topnode = json_loads(payload.c_str(), 0, 0);
if (!topnode)
return FERR_BAD_SYNTAX;
DLOG(INFO) << "Debug event with payload: " << payload;
json_t* cmdnode = json_object_get(topnode, "command");
if (!json_is_string(cmdnode)) {
json_decref(topnode);
return FERR_BAD_SYNTAX;
}
string command = json_string_value(cmdnode);
if (command == "isolate") {
if (con->debugL) {
con->sendDebugReply("Your connection is already running an isolated Lua state.");
} else {
string luamessage;
FReturnCode isolateret = con->isolateLua(luamessage);
if (isolateret == FERR_OK) {
con->sendDebugReply("Your connection is now running an isolated Lua state.");
} else if (isolateret == FERR_LUA) {
string errmsg = "Failed to move your connection into an isolated Lua state. Lua returned the error: " + luamessage;
con->sendDebugReply(errmsg);
} else {
con->sendDebugReply("Failed to move your connection into an isolated Lua state. An unknown error happened.");
}
}
} else if (command == "deisolate") {
if (!con->debugL) {
con->sendDebugReply("Your connection is not currently running an isolated Lua state.");
} else {
con->deisolateLua();
con->sendDebugReply("Your connection has been returned to the global Lua state.");
}
} else if (command == "status") {
//TODO: Make this command do something.
string statusmessage = "Status: ";
if (con->debugL)
statusmessage += "Running isolated. ";
//statusmessage += "Connected from: ";
con->sendDebugReply(statusmessage);
} else if (command == "reload") {
if (con->debugL) {
string luamessage;
FReturnCode reloadret = con->reloadIsolation(luamessage);
if (reloadret == FERR_OK) {
con->sendDebugReply("The isolated Lua state for your connection is now running the latest on disk Lua.");
} else if (reloadret == FERR_LUA) {
string errormsg = "It was not possible to reload the isolated Lua state for your connection because"
" of a Lua error. Lua returned the error: " + luamessage + "\nYou are still running the previous version.";
con->sendDebugReply(errormsg);
} else {
con->sendDebugReply("It was not possible to reload the isolated Lua state for your connection because of an unknown error.\n"
"You are still running the previous version."
);
}
} else {
json_t* argnode = json_object_get(topnode, "arg");
if (!json_is_string(argnode)) {
json_decref(topnode);
return FERR_BAD_SYNTAX;
}
string arg = json_string_value(argnode);
if (arg == "yes") {
string luamessage;
FReturnCode reloadret = Server::reloadLuaState(luamessage);
if (reloadret == FERR_OK) {
con->sendDebugReply("The global Lua state has been reloaded.");
} else if (reloadret == FERR_LUA) {
string errormsg = "It was not possible to reload the global Lua state because of a Lua error. Lua returned the error: "
+ luamessage + "\nEveryone is still running the previous version.";
con->sendDebugReply(errormsg);
} else {
con->sendDebugReply("It was not possible to reload the global Lua state because of an unknown error.\n"
"Everyone is still running the previous version."
);
}
} else {
con->sendDebugReply("You must confirm reloading the global Lua state by providing the argument of \"yes\".");
}
}
} else if (command == "halt") {
Server::startShutdown();
} else if (command == "help") {
con->sendDebugReply(
"Possible commands are: help, status, isolate, deisolate, reload, halt\n"
"help: Prints this message.\n"
"status: Prints information about your connection, including if you are in an isolated Lua state.\n"
"isolate: Attempts to place your connection in an isolated Lua state. Returns a detailed error message upon failure.\n"
"deisolate: Removes your connection from an isolated Lua state if you are in one. Returns a detailed error message upon failure.\n"
"reload: Reloads the Lua code for a state. In a global state you are required to confirm reloading. Returns a detailed error message upon failure.\n"
"halt: This will immediately bring the server down after saving important data."
);
} else {
con->sendDebugReply("Unknown debug command. Try 'help'?");
}
//.........这里部分代码省略.........