diff options
author | deva <deva> | 2011-02-04 13:34:40 +0000 |
---|---|---|
committer | deva <deva> | 2011-02-04 13:34:40 +0000 |
commit | 6bae4fd17d2660d53279dac9287de52be2a00c6c (patch) | |
tree | 595f7aa65558735a3fc05062d39e95e88b026a51 /server/src/admin_connection.cc | |
parent | e6a824034c742b9a414d32ecfbcc8531180f93dc (diff) |
Database pool is now used instead of one connection per session. Admin interface supports session unlock.
Diffstat (limited to 'server/src/admin_connection.cc')
-rw-r--r-- | server/src/admin_connection.cc | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/server/src/admin_connection.cc b/server/src/admin_connection.cc index 517b17a..32cc67e 100644 --- a/server/src/admin_connection.cc +++ b/server/src/admin_connection.cc @@ -27,19 +27,46 @@ */ #include "admin_connection.h" -AdminConnection::AdminConnection(Environment &e, headers_t a) - : env(e), args(a) {} +#include "debug.h" + +static std::string admin_sessionunlock(Environment &env, std::string id) +{ + Session *session = env.sessions.session(id); + if(session) { + if(session->isreadonly) { + env.sessions.deleteSession(id); + return "Session " + id + " was 'readonly' and has been discarded."; + } else { + session->setActive(false); + return "Session " + id + " has been deactivated (set to idle)."; + } + } + return "Session " + id + " does not exist or has been committed."; +} + +AdminConnection::AdminConnection(Environment &e, headers_t a, std::string u) + : env(e), args(a), uri(u) {} AdminConnection::~AdminConnection() {} bool AdminConnection::handle(const char *data, size_t size) { + if(data == NULL && size == 0) { + if(uri == "/sessionunlock" && args.find("id") != args.end()) { + reply = admin_sessionunlock(env, args["id"]); + return true; + } + + reply = "Try something else..."; + return false; + } + return true; } std::string AdminConnection::getResponse() { - return "Hello Admin World"; + return reply; } headers_t AdminConnection::getHeaders() @@ -50,11 +77,8 @@ headers_t AdminConnection::getHeaders() #ifdef TEST_ADMIN_CONNECTION -//Additional dependency files //deps: -//Required cflags (autoconf vars may be used) //cflags: -//Required link options (autoconf vars may be used) //libs: #include "test.h" |