restore compatibility with older Qt
This commit is contained in:
parent
4981372e8f
commit
6595738d64
1 changed files with 4 additions and 0 deletions
|
@ -46,7 +46,9 @@ SMSubServer::SMSubServer(SMSubServerSettings *serverSettings, const QString &soc
|
||||||
SMSubServer::SMSubServer(SMSubServerSettings *serverSettings, const QString &serverName, const quint16 &port) : serverSettings(serverSettings)
|
SMSubServer::SMSubServer(SMSubServerSettings *serverSettings, const QString &serverName, const quint16 &port) : serverSettings(serverSettings)
|
||||||
{
|
{
|
||||||
QWebSocketServer *webSocketServer = new QWebSocketServer(serverName, QWebSocketServer::NonSecureMode, this);
|
QWebSocketServer *webSocketServer = new QWebSocketServer(serverName, QWebSocketServer::NonSecureMode, this);
|
||||||
|
#if QT_VERSION >= 0x060400
|
||||||
webSocketServer->setSupportedSubprotocols(QStringList() << "smsub" << "smsub_json");
|
webSocketServer->setSupportedSubprotocols(QStringList() << "smsub" << "smsub_json");
|
||||||
|
#endif
|
||||||
webSocketServer->listen(QHostAddress::LocalHost, port);
|
webSocketServer->listen(QHostAddress::LocalHost, port);
|
||||||
|
|
||||||
QObject::connect(webSocketServer, &QWebSocketServer::newConnection, this, &SMSubServer::newConnection);
|
QObject::connect(webSocketServer, &QWebSocketServer::newConnection, this, &SMSubServer::newConnection);
|
||||||
|
@ -88,8 +90,10 @@ void SMSubServer::newConnection()
|
||||||
socket = webSocket;
|
socket = webSocket;
|
||||||
QTextStream(stderr) << QString("WebSocket %1:%2 connected!").arg(webSocket->peerAddress().toString(), QString::number(webSocket->peerPort())) << smsub_endl;
|
QTextStream(stderr) << QString("WebSocket %1:%2 connected!").arg(webSocket->peerAddress().toString(), QString::number(webSocket->peerPort())) << smsub_endl;
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x060400
|
||||||
if (webSocket->subprotocol() == "smsub_json")
|
if (webSocket->subprotocol() == "smsub_json")
|
||||||
socket->setProperty("ReceiveJson", true);
|
socket->setProperty("ReceiveJson", true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Just for being sure
|
// Just for being sure
|
||||||
|
|
Loading…
Reference in a new issue