/* PIP - Platform Independent Primitives Introspection module Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "piintrospection_server.h" #include "piintrospection_server_p.h" #include "pichunkstream.h" PRIVATE_DEFINITION_START(PIIntrospectionServer) PIIntrospection::ProcessInfo process_info; PRIVATE_DEFINITION_END(PIIntrospectionServer) PIIntrospectionServer::PIIntrospectionServer(): PIPeer(genName()) { PRIVATE->process_info = PIIntrospection::getInfo(); CONNECTU(&itimer, tickEvent, this, timerEvent); } PIIntrospectionServer::~PIIntrospectionServer() { itimer.stop(false); if (!itimer.waitForFinish(1000)) { PIINTROSPECTION_CONTAINERS->p->mutex.unlock(); } PIPeer::stop(); } void PIIntrospectionServer::start() { itimer.start(1000); PIPeer::start(); } PIString PIIntrospectionServer::genName() { randomize(); return "__introspection__server_" + PIString::fromNumber(randomi() % 1000); } void PIIntrospectionServer::timerEvent() { PIChunkStream cs; cs.add(1, PIIntrospection::packInfo()) .add(2, PIIntrospection::packContainers()) .add(3, PIIntrospection::packThreads()) .add(4, PIIntrospection::packObjects()); PIByteArray ba; ba << PIIntrospection::sign; ba.append(cs.data()); send("__introspection_client__", ba); }