2 QWebSockets implements the WebSocket protocol as defined in RFC 6455.
3 Copyright (C) 2013 Kurt Pattyn (pattyn.kurt@gmail.com)
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef QWEBSOCKETSERVER_H
21 #define QWEBSOCKETSERVER_H
25 #include <QHostAddress>
27 #include "QtWebSockets/qwebsockets_global.h"
28 #include "QtWebSockets/qwebsocketprotocol.h"
32 class QWebSocketServerPrivate;
34 class QWebSocketCorsAuthenticator;
36 class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject
39 Q_DISABLE_COPY(QWebSocketServer)
40 Q_DECLARE_PRIVATE(QWebSocketServer)
43 explicit QWebSocketServer(const QString &serverName, QObject *parent = 0);
44 virtual ~QWebSocketServer();
46 bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
49 bool isListening() const;
51 void setMaxPendingConnections(int numConnections);
52 int maxPendingConnections() const;
54 quint16 serverPort() const;
55 QHostAddress serverAddress() const;
57 bool setSocketDescriptor(int socketDescriptor);
58 int socketDescriptor() const;
60 bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
61 bool hasPendingConnections() const;
62 virtual QWebSocket *nextPendingConnection();
64 QAbstractSocket::SocketError serverError() const;
65 QString errorString() const;
67 void pauseAccepting();
68 void resumeAccepting();
70 void setServerName(const QString &serverName);
71 QString serverName() const;
73 #ifndef QT_NO_NETWORKPROXY
74 void setProxy(const QNetworkProxy &networkProxy);
75 QNetworkProxy proxy() const;
78 QList<QWebSocketProtocol::Version> supportedVersions() const;
79 QList<QString> supportedProtocols() const;
80 QList<QString> supportedExtensions() const;
83 void acceptError(QAbstractSocket::SocketError socketError);
84 void originAuthenticationRequired(QWebSocketCorsAuthenticator *pAuthenticator);
88 QWebSocketServerPrivate * const d_ptr;
93 #endif // QWEBSOCKETSERVER_H