mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:01:15 +02:00
Merge pull request #3311 from huffman/fix-wm-close
Update assignment client to close on WM_CLOSE message on Windows
This commit is contained in:
commit
9036954d38
8 changed files with 127 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <Assignment.h>
|
#include <Assignment.h>
|
||||||
#include <HifiConfigVariantMap.h>
|
#include <HifiConfigVariantMap.h>
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
|
#include <LogUtils.h>
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
@ -36,13 +37,19 @@ int hifiSockAddrMeta = qRegisterMetaType<HifiSockAddr>("HifiSockAddr");
|
||||||
|
|
||||||
AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||||
QCoreApplication(argc, argv),
|
QCoreApplication(argc, argv),
|
||||||
_assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME)
|
_assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME),
|
||||||
|
_shutdownEventListener(this)
|
||||||
{
|
{
|
||||||
|
LogUtils::init();
|
||||||
|
|
||||||
setOrganizationName("High Fidelity");
|
setOrganizationName("High Fidelity");
|
||||||
setOrganizationDomain("highfidelity.io");
|
setOrganizationDomain("highfidelity.io");
|
||||||
setApplicationName("assignment-client");
|
setApplicationName("assignment-client");
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
|
|
||||||
|
installNativeEventFilter(&_shutdownEventListener);
|
||||||
|
connect(&_shutdownEventListener, SIGNAL(receivedCloseEvent()), SLOT(quit()));
|
||||||
|
|
||||||
// set the logging target to the the CHILD_TARGET_NAME
|
// set the logging target to the the CHILD_TARGET_NAME
|
||||||
Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
|
Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
|
#include "ShutdownEventListener.h"
|
||||||
#include "ThreadedAssignment.h"
|
#include "ThreadedAssignment.h"
|
||||||
|
|
||||||
class AssignmentClient : public QCoreApplication {
|
class AssignmentClient : public QCoreApplication {
|
||||||
|
@ -21,6 +22,7 @@ class AssignmentClient : public QCoreApplication {
|
||||||
public:
|
public:
|
||||||
AssignmentClient(int &argc, char **argv);
|
AssignmentClient(int &argc, char **argv);
|
||||||
static const SharedAssignmentPointer& getCurrentAssignment() { return _currentAssignment; }
|
static const SharedAssignmentPointer& getCurrentAssignment() { return _currentAssignment; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void sendAssignmentRequest();
|
void sendAssignmentRequest();
|
||||||
void readPendingDatagrams();
|
void readPendingDatagrams();
|
||||||
|
@ -30,6 +32,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
Assignment _requestAssignment;
|
Assignment _requestAssignment;
|
||||||
static SharedAssignmentPointer _currentAssignment;
|
static SharedAssignmentPointer _currentAssignment;
|
||||||
|
ShutdownEventListener _shutdownEventListener;
|
||||||
QString _assignmentServerHostname;
|
QString _assignmentServerHostname;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
#include <HifiConfigVariantMap.h>
|
#include <HifiConfigVariantMap.h>
|
||||||
#include <HTTPConnection.h>
|
#include <HTTPConnection.h>
|
||||||
|
#include <LogUtils.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <UUID.h>
|
#include <UUID.h>
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
|
|
||||||
DomainServer::DomainServer(int argc, char* argv[]) :
|
DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
QCoreApplication(argc, argv),
|
QCoreApplication(argc, argv),
|
||||||
|
_shutdownEventListener(this),
|
||||||
_httpManager(DOMAIN_SERVER_HTTP_PORT, QString("%1/resources/web/").arg(QCoreApplication::applicationDirPath()), this),
|
_httpManager(DOMAIN_SERVER_HTTP_PORT, QString("%1/resources/web/").arg(QCoreApplication::applicationDirPath()), this),
|
||||||
_httpsManager(NULL),
|
_httpsManager(NULL),
|
||||||
_allAssignments(),
|
_allAssignments(),
|
||||||
|
@ -46,10 +48,16 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
_cookieSessionHash(),
|
_cookieSessionHash(),
|
||||||
_settingsManager()
|
_settingsManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
LogUtils::init();
|
||||||
|
|
||||||
setOrganizationName("High Fidelity");
|
setOrganizationName("High Fidelity");
|
||||||
setOrganizationDomain("highfidelity.io");
|
setOrganizationDomain("highfidelity.io");
|
||||||
setApplicationName("domain-server");
|
setApplicationName("domain-server");
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
|
|
||||||
|
installNativeEventFilter(&_shutdownEventListener);
|
||||||
|
connect(&_shutdownEventListener, SIGNAL(receivedCloseEvent()), SLOT(quit()));
|
||||||
|
|
||||||
qRegisterMetaType<DomainServerWebSessionData>("DomainServerWebSessionData");
|
qRegisterMetaType<DomainServerWebSessionData>("DomainServerWebSessionData");
|
||||||
qRegisterMetaTypeStreamOperators<DomainServerWebSessionData>("DomainServerWebSessionData");
|
qRegisterMetaTypeStreamOperators<DomainServerWebSessionData>("DomainServerWebSessionData");
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
|
|
||||||
#include <Assignment.h>
|
#include <Assignment.h>
|
||||||
#include <HTTPSConnection.h>
|
#include <HTTPSConnection.h>
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
|
|
||||||
#include "DomainServerSettingsManager.h"
|
#include "DomainServerSettingsManager.h"
|
||||||
#include "DomainServerWebSessionData.h"
|
#include "DomainServerWebSessionData.h"
|
||||||
|
#include "ShutdownEventListener.h"
|
||||||
#include "WalletTransaction.h"
|
#include "WalletTransaction.h"
|
||||||
|
|
||||||
#include "PendingAssignedNodeData.h"
|
#include "PendingAssignedNodeData.h"
|
||||||
|
@ -97,6 +99,8 @@ private:
|
||||||
|
|
||||||
QJsonObject jsonForSocket(const HifiSockAddr& socket);
|
QJsonObject jsonForSocket(const HifiSockAddr& socket);
|
||||||
QJsonObject jsonObjectForNode(const SharedNodePointer& node);
|
QJsonObject jsonObjectForNode(const SharedNodePointer& node);
|
||||||
|
|
||||||
|
ShutdownEventListener _shutdownEventListener;
|
||||||
|
|
||||||
HTTPManager _httpManager;
|
HTTPManager _httpManager;
|
||||||
HTTPSManager* _httpsManager;
|
HTTPSManager* _httpsManager;
|
||||||
|
|
24
libraries/shared/src/LogUtils.cpp
Normal file
24
libraries/shared/src/LogUtils.cpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// LogUtils.cpp
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/03/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "LogUtils.h"
|
||||||
|
|
||||||
|
void LogUtils::init() {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// Windows applications buffer stdout/err hard when not run from a terminal,
|
||||||
|
// making assignment clients run from the Stack Manager application not flush
|
||||||
|
// log messages.
|
||||||
|
// This will disable the buffering. If this becomes a performance issue,
|
||||||
|
// an alternative is to call fflush(...) periodically.
|
||||||
|
setbuf(stdout, NULL);
|
||||||
|
setbuf(stderr, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
20
libraries/shared/src/LogUtils.h
Normal file
20
libraries/shared/src/LogUtils.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
//
|
||||||
|
// LogUtils.h
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/03/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_LogUtils_h
|
||||||
|
#define hifi_LogUtils_h
|
||||||
|
|
||||||
|
class LogUtils {
|
||||||
|
public:
|
||||||
|
static void init();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_LogUtils_h
|
31
libraries/shared/src/ShutdownEventListener.cpp
Normal file
31
libraries/shared/src/ShutdownEventListener.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
//
|
||||||
|
// ShutdownEventListener.cpp
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/03/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ShutdownEventListener.h"
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ShutdownEventListener::ShutdownEventListener(QObject* parent) : QObject(parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShutdownEventListener::nativeEventFilter(const QByteArray &eventType, void* msg, long* result) {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
if (eventType == "windows_generic_MSG") {
|
||||||
|
MSG* message = (MSG*)msg;
|
||||||
|
if (message->message == WM_CLOSE) {
|
||||||
|
emit receivedCloseEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
29
libraries/shared/src/ShutdownEventListener.h
Normal file
29
libraries/shared/src/ShutdownEventListener.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// ShutdownEventListener.h
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/03/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_ShutdownEventListener_h
|
||||||
|
#define hifi_ShutdownEventListener_h
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
|
|
||||||
|
class ShutdownEventListener : public QObject, public QAbstractNativeEventFilter {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ShutdownEventListener(QObject* parent = NULL);
|
||||||
|
|
||||||
|
virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long* result);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void receivedCloseEvent();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_ShutdownEventListener_h
|
Loading…
Reference in a new issue