This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 6ec90477ce7e437ed2ad29514b9e1bc65dca3ad4 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Wed Aug 22 14:12:42 2018 +0200 If client is configured to send events, the broker can ask client to send ALIVE events. To do this, broker should send config option "liveevent" (int). It means, if liveevent=10, client will send ALIVE event to broker every 10 seconds when the client connected to X2Go Session. --- debian/changelog | 4 ++++ src/httpbrokerclient.cpp | 5 +++++ src/onmainwindow.cpp | 27 +++++++++++++++++++++++---- src/onmainwindow.h | 6 +++++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index d497840..cdb3712 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,10 @@ x2goclient (4.1.2.2-0x2go1) UNRELEASED; urgency=medium but rather the state of X2Go Client. - Save session command in resumingSession.command. - Send in broker event the duration of session on client. + - If client is configured to send events, the broker can ask client to send + ALIVE events. To do this, broker should send config option "liveevent" (int). + It means, if liveevent=10, client will send ALIVE event to broker every 10 + seconds when the client connected to X2Go Session. [ Mihai Moldovan ] * New upstream version (4.1.2.2): diff --git a/src/httpbrokerclient.cpp b/src/httpbrokerclient.cpp index 002785b..b12961f 100644 --- a/src/httpbrokerclient.cpp +++ b/src/httpbrokerclient.cpp @@ -473,9 +473,14 @@ void HttpBrokerClient::processClientConfig(const QString& raw_content) { X2goSettings st(raw_content, QSettings::IniFormat); mainWindow->config.brokerEvents=st.setting()->value("events",false).toBool(); + mainWindow->config.brokerLiveEventsTimeout=st.setting()->value("liveevent",false).toUInt(); if(mainWindow->config.brokerEvents) { x2goDebug<<"sending client events to broker"; + if(mainWindow->config.brokerLiveEventsTimeout) + { + x2goDebug<<"sending alive events to broker every "<<mainWindow->config.brokerLiveEventsTimeout<<" seconds"; + } } } diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index bf97c9e..e5a9855 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -197,6 +197,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) isPassShown=true; readExportsFrom=QString::null; spoolTimer=0l; + brokerAliveTimer=0l; #ifdef Q_OS_DARWIN modMapTimer = NULL; kbMap = QString (); @@ -549,6 +550,9 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) connect ( broker, SIGNAL ( sessionSelected()), this, SLOT (slotGetBrokerSession())); connect ( broker, SIGNAL ( passwordChanged(QString)), this, SLOT ( slotPassChanged(QString))); connect (broker, SIGNAL (enableBrokerLogoutButton ()), this, SLOT (slotEnableBrokerLogoutButton ())); + brokerAliveTimer=new QTimer(this); + connect ( brokerAliveTimer, SIGNAL ( timeout() ), this, + SLOT ( slotSendBrokerAlive() ) ); } proxyWinTimer=new QTimer ( this ); @@ -608,6 +612,12 @@ void ONMainWindow::slotBrokerLogoutButton () { } +void ONMainWindow::slotSendBrokerAlive() +{ + sendEventToBroker(ALIVE); +} + + void ONMainWindow::slotSyncX() { if (proxyRunning) @@ -4002,11 +4012,12 @@ void ONMainWindow::sendEventToBroker(ONMainWindow::client_events ev) { return; } - if(ev <= lastBrokerEvent && resumingSession.sessionId == lastBrokerEventSession ) + if(ev <= lastBrokerEvent && resumingSession.sessionId == lastBrokerEventSession && ev != ALIVE) { return; } - lastBrokerEvent=ev; + if(ev!=ALIVE) + lastBrokerEvent=ev; lastBrokerEventSession=resumingSession.sessionId; QString event; switch(ev) @@ -4021,6 +4032,8 @@ void ONMainWindow::sendEventToBroker(ONMainWindow::client_events ev) { event="CONNECTED"; resumingSession.connectedSince=QDateTime::currentDateTime().toTime_t(); + if(config.brokerLiveEventsTimeout) + brokerAliveTimer->start(config.brokerLiveEventsTimeout*1000); break; } case SUSPENDING: @@ -4036,12 +4049,18 @@ void ONMainWindow::sendEventToBroker(ONMainWindow::client_events ev) case FINISHED: { event="FINISHED"; + brokerAliveTimer->stop(); + break; + } + case ALIVE: + { + event="ALIVE"; break; } } broker->sendEvent(event, resumingSession.sessionId,resumingSession.server, resumingSession.clientIp, getCurrentUname(), - resumingSession.command, resumingSession.display, resumingSession.crTime, - QDateTime::currentDateTime().toTime_t()-resumingSession.connectedSince); + resumingSession.command, resumingSession.display, resumingSession.crTime, + QDateTime::currentDateTime().toTime_t()-resumingSession.connectedSince); } diff --git a/src/onmainwindow.h b/src/onmainwindow.h index 0abf74a..3996e43 100644 --- a/src/onmainwindow.h +++ b/src/onmainwindow.h @@ -170,6 +170,7 @@ struct ConfigFile bool brokerAutologoff; bool brokerKrbLogin; bool brokerEvents; //Send events to broker and get control commands + uint brokerLiveEventsTimeout; //(seconds)How often send alive events, 0 - do not send QString brokerSshKey; QString brokerCaCertFile; QString iniFile; @@ -306,7 +307,8 @@ public: CONNECTED, SUSPENDING, TERMINATING, - FINISHED + FINISHED, + ALIVE }; static bool debugging; @@ -724,6 +726,7 @@ private: QTimer *spoolTimer; QTimer *proxyWinTimer; QTimer *xineramaTimer; + QTimer *brokerAliveTimer; short xinSizeInc; QRect lastDisplayGeometry; QList <QRect> xineramaScreens; @@ -1051,6 +1054,7 @@ public slots: void slotEnableBrokerLogoutButton (); private slots: + void slotSendBrokerAlive(); void slotShowPAMSGDialog(bool error, const QString& main_text, const QString& info_text, bool modal); void slotSnameChanged ( const QString& ); void slotSelectedFromList ( SessionButton* session ); -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git