mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
Commit some debugging work on the sysadm server.
This commit is contained in:
@@ -56,7 +56,7 @@ void EventWatcher::WatcherUpdate(QString path){
|
||||
qDebug() << "Dispatcher Update:" << stat;
|
||||
HASH.insert(DISPATCHER,stat); //save for later
|
||||
//Forward those contents on to the currently-open sockets
|
||||
emit NewEvent(DISPATCHER, stat);
|
||||
emit NewEvent(DISPATCHER, QJsonValue(stat) );
|
||||
}else if(path==LPLOG){
|
||||
//Main Life Preserver Log File
|
||||
|
||||
|
||||
@@ -46,6 +46,6 @@ private slots:
|
||||
void WatcherUpdate(QString);
|
||||
|
||||
signals:
|
||||
void NewEvent(EVENT_TYPE ev, QJsonValue); //type/message
|
||||
void NewEvent(EventWatcher::EVENT_TYPE, QJsonValue); //type/message
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
if(message.isEmpty()){ return; }
|
||||
//Pull out any REST headers
|
||||
Body = message;
|
||||
qDebug() << "Raw Message:" << message;
|
||||
//qDebug() << "Raw Message:" << message;
|
||||
if(!message.startsWith("{")){
|
||||
Header = message.section("{",0,0).split("\n");
|
||||
Body = "{"+message.section("{",1, 1000000);
|
||||
|
||||
@@ -254,7 +254,9 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmUpdateRequest(const QJsonVal
|
||||
QString act = JsonValueToString(in_args.toObject().value("action"));
|
||||
if(act=="checkupdates"){
|
||||
ok = true;
|
||||
qDebug() << " - Starting update check";
|
||||
out->insert("checkupdates", sysadm::Update::checkUpdates());
|
||||
qDebug() << " - Finished update check";
|
||||
}
|
||||
|
||||
} //end of "action" key usage
|
||||
|
||||
@@ -15,10 +15,6 @@ WebServer::WebServer(){
|
||||
WSServer = 0;
|
||||
TCPServer = 0;
|
||||
AUTH = new AuthorizationManager();
|
||||
//watcher = new QFileSystemWatcher(this);
|
||||
|
||||
//connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(WatcherUpdate(QString)) );
|
||||
//connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(WatcherUpdate(QString)) );
|
||||
}
|
||||
|
||||
WebServer::~WebServer(){
|
||||
@@ -124,7 +120,7 @@ void WebServer::NewSocketConnection(){
|
||||
if(sock==0){ return; } //no new connection
|
||||
qDebug() << "New Socket Connection";
|
||||
connect(sock, SIGNAL(SocketClosed(QString)), this, SLOT(SocketClosed(QString)) );
|
||||
connect(EVENTS, SIGNAL(NewEvent(EventWatcher::EVENT_TYPE, QString)), sock, SLOT(EventUpdate(EventWatcher::EVENT_TYPE, QString)) );
|
||||
connect(EVENTS, SIGNAL(NewEvent(EventWatcher::EVENT_TYPE, QJsonValue)), sock, SLOT(EventUpdate(EventWatcher::EVENT_TYPE, QJsonValue)) );
|
||||
OpenSockets << sock;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ WebSocket::WebSocket(QSslSocket *sock, QString ID, AuthorizationManager *auth){
|
||||
}
|
||||
|
||||
WebSocket::~WebSocket(){
|
||||
qDebug() << "SOCKET Destroyed";
|
||||
if(SOCKET!=0){
|
||||
SOCKET->close();
|
||||
delete SOCKET;
|
||||
@@ -68,8 +69,8 @@ QString WebSocket::ID(){
|
||||
//=======================
|
||||
void WebSocket::sendReply(QString msg){
|
||||
qDebug() << "Sending Socket Reply";
|
||||
if(SOCKET!=0){ SOCKET->sendTextMessage(msg); } //Websocket connection
|
||||
else if(TSOCKET!=0){
|
||||
if(SOCKET!=0 && SOCKET->isValid()){ SOCKET->sendTextMessage(msg); } //Websocket connection
|
||||
else if(TSOCKET!=0 && TSOCKET->isValid()){
|
||||
//TCP Socket connection
|
||||
TSOCKET->write(msg.toUtf8().data());
|
||||
TSOCKET->disconnectFromHost(); //TCP/REST connections are 1 connection per message.
|
||||
@@ -280,10 +281,13 @@ void WebSocket::checkIdle(){
|
||||
}
|
||||
|
||||
void WebSocket::SocketClosing(){
|
||||
qDebug() << "Socket Closing...";
|
||||
qDebug() << "Socket Closing..." ;
|
||||
if(idletimer->isActive()){
|
||||
//This means the client deliberately closed the connection - not the idle timer
|
||||
qDebug() << " - Client Closed Connection";
|
||||
idletimer->stop();
|
||||
}else{
|
||||
qDebug() << "idleTimer not running";
|
||||
}
|
||||
//Stop any current requests
|
||||
|
||||
@@ -297,16 +301,16 @@ void WebSocket::SocketClosing(){
|
||||
void WebSocket::EvaluateMessage(const QByteArray &msg){
|
||||
qDebug() << "New Binary Message:";
|
||||
if(idletimer->isActive()){ idletimer->stop(); }
|
||||
EvaluateREST( QString(msg) );
|
||||
idletimer->start();
|
||||
EvaluateREST( QString(msg) );
|
||||
qDebug() << " - Done with Binary Message";
|
||||
}
|
||||
|
||||
void WebSocket::EvaluateMessage(const QString &msg){
|
||||
qDebug() << "New Text Message:";
|
||||
if(idletimer->isActive()){ idletimer->stop(); }
|
||||
EvaluateREST(msg);
|
||||
idletimer->start();
|
||||
EvaluateREST(msg);
|
||||
qDebug() << " - Done with Text Message";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user