Commit 2d37412c authored by Pavel Vainerman's avatar Pavel Vainerman

[uwebsocket]: added "getInfo"

parent 8e2c4255
......@@ -181,6 +181,30 @@ void UWebSocketGate::sensorInfo( const SensorMessage* sm )
s->sensorInfo(sm);
}
//--------------------------------------------------------------------------------------------
uniset::SimpleInfo* UWebSocketGate::getInfo( const char* userparam )
{
uniset::SimpleInfo_var i = UniSetObject::getInfo(userparam);
ostringstream inf;
inf << i->info << endl;
// inf << vmon.pretty_str() << endl;
inf << endl;
{
uniset_rwmutex_wrlock lock(wsocksMutex);
inf << "websockets[" << wsocks.size() << "]: " << endl;
for( auto&& s : wsocks )
{
inf << " " << s->getInfo() << endl;
}
}
i->info = inf.str().c_str();
return i._retn();
}
//--------------------------------------------------------------------------------------------
Poco::JSON::Object::Ptr UWebSocketGate::UWebSocket::to_short_json( sinfo* si )
{
Poco::JSON::Object::Ptr json = new Poco::JSON::Object();
......@@ -638,6 +662,21 @@ UWebSocketGate::UWebSocket::~UWebSocket()
}
}
// -----------------------------------------------------------------------------
std::string UWebSocketGate::UWebSocket::getInfo() const noexcept
{
ostringstream inf;
inf << req->clientAddress().toString()
<< ": jbuf=" << jbuf.size()
<< " wbuf=" << wbuf.size()
<< " ping_sec=" << ping_sec
<< " maxsend=" << maxsend
<< " send_sec=" << send_sec
<< " maxcmd=" << maxcmd;
return inf.str();
}
// -----------------------------------------------------------------------------
bool UWebSocketGate::UWebSocket::isActive()
{
return iosend.is_active();
......
......@@ -241,6 +241,7 @@ namespace uniset
void checkMessages( ev::timer& t, int revents );
virtual void sensorInfo( const uniset::SensorMessage* sm ) override;
virtual uniset::SimpleInfo* getInfo( const char* userparam = 0 ) override;
ev::timer iocheck;
double check_sec = { 0.05 };
int maxMessagesProcessing = { 100 };
......@@ -277,6 +278,8 @@ namespace uniset
virtual ~UWebSocket();
std::string getInfo() const noexcept;
bool isActive();
void set( ev::dynamic_loop& loop, std::shared_ptr<ev::async> a );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment