print all open sessions to console for debug reasons only...
parent
7e16aa6611
commit
6d1a5c9833
|
@ -294,6 +294,30 @@ void OnApiRequest(evhttp_request* req, void* obj)
|
|||
} // end of anonymous namespace
|
||||
|
||||
|
||||
std::string getSessions()
|
||||
{
|
||||
js::Array a;
|
||||
a.reserve(session_registry.size());
|
||||
for(const auto& s : session_registry)
|
||||
{
|
||||
std::stringstream ss;
|
||||
js::Object o;
|
||||
ss << s.first;
|
||||
o.emplace_back("tid", ss.str() );
|
||||
ss.str("");
|
||||
ss << static_cast<void*>(s.second);
|
||||
o.emplace_back("session", ss.str() );
|
||||
if(s.first == std::this_thread::get_id())
|
||||
{
|
||||
o.emplace_back("mine", true);
|
||||
}
|
||||
a.push_back( std::move(o) );
|
||||
}
|
||||
|
||||
return js::write( a, js::pretty_print | js::raw_utf8 | js::single_line_arrays );
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
PEP_SESSION from_json(const js::Value& v)
|
||||
{
|
||||
|
|
|
@ -53,4 +53,9 @@ private:
|
|||
Internal* i; // pimpl for stable interface.
|
||||
};
|
||||
|
||||
// just for debug:
|
||||
// returns a string with a pretty-printed JSON array containing the session registry
|
||||
std::string getSessions();
|
||||
|
||||
|
||||
#endif // JSON_ADAPTER_HH
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "json_rpc.hh"
|
||||
#include "json_spirit/json_spirit_utils.h"
|
||||
#include "json_spirit/json_spirit_writer.h"
|
||||
|
||||
#include "json-adapter.hh"
|
||||
#include "security-token.hh"
|
||||
|
||||
|
||||
|
@ -100,6 +100,7 @@ js::Object call(const FunctionMap& fm, const js::Object& request, const std::str
|
|||
"\tparams=" << js::write(params) << ". ===\n";
|
||||
const js::Value result = fn->second->call(p);
|
||||
std::cerr << "=== Result of call: " << js::write(result, js::raw_utf8) << ". ===\n";
|
||||
std::cerr << "\tSessions: " << getSessions() << "\n";
|
||||
|
||||
return make_result(result, request_id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue