From 26f54ff4f0a13a909331d2aa80d29244af4062bb Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 2 May 2016 14:57:49 -0400 Subject: [PATCH] Simply the server layout of the bridge --- src/bridge/BridgeConnection.cpp | 3 ++- src/bridge/BridgeServer.cpp | 3 +-- src/bridge/globals.h | 2 ++ src/bridge/main.cpp | 21 +++++---------------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/bridge/BridgeConnection.cpp b/src/bridge/BridgeConnection.cpp index 71d913b..1a06c87 100644 --- a/src/bridge/BridgeConnection.cpp +++ b/src/bridge/BridgeConnection.cpp @@ -18,7 +18,7 @@ BridgeConnection::BridgeConnection(QWebSocket *sock, QString ID){ idletimer = new QTimer(this); idletimer->setInterval(IDLETIMEOUTMINS*60000); //connection timout for idle sockets idletimer->setSingleShot(true); - connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) ); + connect(idletimer, SIGNAL(timeout()), this, SLOT(checkgonintendoIdle()) ); connect(SOCKET, SIGNAL(textMessageReceived(const QString&)), this, SLOT(EvaluateMessage(const QString&)) ); connect(SOCKET, SIGNAL(binaryMessageReceived(const QByteArray&)), this, SLOT(EvaluateMessage(const QByteArray&)) ); connect(SOCKET, SIGNAL(aboutToClose()), this, SLOT(SocketClosing()) ); @@ -42,6 +42,7 @@ void BridgeConnection::forwardMessage(QString msg){ //qDebug() << "Sending Socket Reply:" << msg; if(SOCKET!=0 && SOCKET->isValid()){ SOCKET->sendTextMessage(msg); } } + //======================= // PRIVATE //======================= diff --git a/src/bridge/BridgeServer.cpp b/src/bridge/BridgeServer.cpp index 7e73694..1cc5bb9 100644 --- a/src/bridge/BridgeServer.cpp +++ b/src/bridge/BridgeServer.cpp @@ -75,7 +75,6 @@ bool BridgeServer::setupWebSocket(quint16 port){ //Setup Connections connect(this, SIGNAL(newConnection()), this, SLOT(NewSocketConnection()) ); connect(this, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(NewConnectError(QAbstractSocket::SocketError)) ); - // -- websocket specific signals connect(this, SIGNAL(closed()), this, SLOT(ServerClosed()) ); connect(this, SIGNAL(serverError(QWebSocketProtocol::CloseCode)), this, SLOT(ServerError(QWebSocketProtocol::CloseCode)) ); connect(this, SIGNAL(originAuthenticationRequired(QWebSocketCorsAuthenticator*)), this, SLOT(OriginAuthRequired(QWebSocketCorsAuthenticator*)) ); @@ -125,7 +124,7 @@ void BridgeServer::NewSocketConnection(){ if(sock==0){ return; } //no new connection //qDebug() << "New Socket Connection"; connect(sock, SIGNAL(SocketClosed(QString)), this, SLOT(SocketClosed(QString)) ); - connect(sock, SIGNAL(SocketMessage(QString, QString)), this, SIGNAL(ForwardMessage(QString, QString)) ); + connect(sock, SIGNAL(SocketMessage(QString, QString)), this, SLOT(SendMessage(QString, QString)) ); OpenSockets << sock; } diff --git a/src/bridge/globals.h b/src/bridge/globals.h index 6c85a97..890eaa4 100644 --- a/src/bridge/globals.h +++ b/src/bridge/globals.h @@ -22,6 +22,8 @@ #include #include #include +#include + #include #include #include diff --git a/src/bridge/main.cpp b/src/bridge/main.cpp index 8a978b8..4a7a9aa 100644 --- a/src/bridge/main.cpp +++ b/src/bridge/main.cpp @@ -51,8 +51,7 @@ void MessageOutput(QtMsgType type, const QMessageLogContext &context, const QStr int main( int argc, char ** argv ) { //Evaluate input arguments - quint16 cport = 12148; //client-side port number - quint16 sport = 12149; //server-side port number + quint16 port = 12149; //port number bool settingchange = false; for(int i=1; isetValue("blacklist_settings/blockmins",val.toInt()); } } - else if( QString(argv[i])=="-clientport" && (i+1