mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 02:53:56 -07:00
* fix #3225 * Servatrice: use websockets as an optional component (for qt < 5.3) * Attempt++
This commit is contained in:
parent
73fb9ee03e
commit
c06fc562a1
9 changed files with 72 additions and 152 deletions
|
|
@ -36,42 +36,23 @@ if(APPLE)
|
|||
set(servatrice_SOURCES ${servatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
|
||||
ENDIF(APPLE)
|
||||
|
||||
set(SERVATRICE_LIBS)
|
||||
# Qt5
|
||||
find_package(Qt5 COMPONENTS Network Sql REQUIRED)
|
||||
include_directories(${Qt5Core_INCLUDE_DIRS})
|
||||
include_directories(${Qt5Network_INCLUDE_DIRS})
|
||||
include_directories(${Qt5Sql_INCLUDE_DIRS})
|
||||
set(SERVATRICE_QT_MODULES Core Network Sql)
|
||||
|
||||
# qt5 stuff
|
||||
if(Qt5Widgets_FOUND)
|
||||
include_directories(${Qt5Widgets_INCLUDE_DIRS})
|
||||
list(APPEND SERVATRICE_LIBS Widgets)
|
||||
|
||||
# QtNetwork
|
||||
find_package(Qt5Network)
|
||||
if(Qt5Network_FOUND)
|
||||
include_directories(${Qt5Network_INCLUDE_DIRS})
|
||||
list(APPEND SERVATRICE_LIBS Network)
|
||||
endif()
|
||||
|
||||
# QtSql
|
||||
find_package(Qt5Sql)
|
||||
if(Qt5Sql_FOUND)
|
||||
include_directories(${Qt5Sql_INCLUDE_DIRS})
|
||||
list(APPEND SERVATRICE_LIBS Sql)
|
||||
endif()
|
||||
|
||||
# QtWebsockets
|
||||
find_package(Qt5WebSockets)
|
||||
if(Qt5WebSockets_FOUND)
|
||||
include_directories(${Qt5WebSockets_INCLUDE_DIRS})
|
||||
list(APPEND SERVATRICE_LIBS WebSockets)
|
||||
endif()
|
||||
|
||||
QT5_ADD_RESOURCES(servatrice_RESOURCES_RCC ${servatrice_RESOURCES})
|
||||
|
||||
# guess plugins and libraries directory
|
||||
set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins")
|
||||
get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION)
|
||||
get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
|
||||
# Qt Websockets
|
||||
find_package(Qt5WebSockets)
|
||||
if(Qt5WebSockets_FOUND)
|
||||
include_directories(${Qt5WebSockets_INCLUDE_DIRS})
|
||||
list(APPEND SERVATRICE_QT_MODULES WebSockets)
|
||||
else()
|
||||
MESSAGE(WARNING "Qt5 websocket module not found")
|
||||
endif()
|
||||
|
||||
QT5_ADD_RESOURCES(servatrice_RESOURCES_RCC ${servatrice_RESOURCES})
|
||||
SET(QT_DONT_USE_QTGUI TRUE)
|
||||
|
||||
# Mysql connector
|
||||
|
|
@ -114,7 +95,7 @@ if(MSVC)
|
|||
else()
|
||||
TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
qt5_use_modules(servatrice ${SERVATRICE_LIBS})
|
||||
qt5_use_modules(servatrice ${SERVATRICE_QT_MODULES})
|
||||
|
||||
# install rules
|
||||
if(UNIX)
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ Servatrice_ConnectionPool *Servatrice_GameServer::findLeastUsedConnectionPool()
|
|||
return connectionPools[poolIndex];
|
||||
}
|
||||
|
||||
#if QT_VERSION > 0x050300
|
||||
#ifdef QT_WEBSOCKETS_LIB
|
||||
#define WEBSOCKET_POOL_NUMBER 999
|
||||
|
||||
Servatrice_WebsocketGameServer::Servatrice_WebsocketGameServer(Servatrice *_server,
|
||||
|
|
@ -430,7 +430,7 @@ bool Servatrice::initServer()
|
|||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION > 0x050300
|
||||
#ifdef QT_WEBSOCKETS_LIB
|
||||
// WEBSOCKET SERVER
|
||||
if (getNumberOfWebSocketPools() > 0) {
|
||||
websocketGameServer = new Servatrice_WebsocketGameServer(this, getNumberOfWebSocketPools(),
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#define SERVATRICE_H
|
||||
|
||||
#include <QTcpServer>
|
||||
#if QT_VERSION > 0x050300
|
||||
#ifdef QT_WEBSOCKETS_LIB
|
||||
#include <QWebSocketServer>
|
||||
#endif
|
||||
#include "server.h"
|
||||
|
|
@ -66,7 +66,7 @@ protected:
|
|||
Servatrice_ConnectionPool *findLeastUsedConnectionPool();
|
||||
};
|
||||
|
||||
#if QT_VERSION > 0x050300
|
||||
#ifdef QT_WEBSOCKETS_LIB
|
||||
class Servatrice_WebsocketGameServer : public QWebSocketServer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -158,7 +158,7 @@ private:
|
|||
DatabaseType databaseType;
|
||||
QTimer *pingClock, *statusUpdateClock;
|
||||
Servatrice_GameServer *gameServer;
|
||||
#if QT_VERSION > 0x050300
|
||||
#ifdef QT_WEBSOCKETS_LIB
|
||||
Servatrice_WebsocketGameServer *websocketGameServer;
|
||||
#endif
|
||||
Servatrice_IslServer *islServer;
|
||||
|
|
|
|||
|
|
@ -1629,7 +1629,7 @@ bool TcpServerSocketInterface::initTcpSession()
|
|||
return true;
|
||||
}
|
||||
|
||||
#if QT_VERSION > 0x050300
|
||||
#ifdef QT_WEBSOCKETS_LIB
|
||||
WebsocketServerSocketInterface::WebsocketServerSocketInterface(Servatrice *_server,
|
||||
Servatrice_DatabaseInterface *_databaseInterface,
|
||||
QObject *parent)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#define SERVERSOCKETINTERFACE_H
|
||||
|
||||
#include <QTcpSocket>
|
||||
#if QT_VERSION > 0x050300
|
||||
#ifdef QT_WEBSOCKETS_LIB
|
||||
#include <QWebSocket>
|
||||
#endif
|
||||
#include "server_protocolhandler.h"
|
||||
|
|
@ -181,7 +181,7 @@ public slots:
|
|||
void initConnection(int socketDescriptor);
|
||||
};
|
||||
|
||||
#if QT_VERSION > 0x050300
|
||||
#ifdef QT_WEBSOCKETS_LIB
|
||||
class WebsocketServerSocketInterface : public AbstractServerSocketInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue