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>
26 #include "qwebsocketsglobal.h"
27 #include "qwebsocketprotocol.h"
31 class QWebSocketServerPrivate;
34 class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject
39 explicit QWebSocketServer(const QString &serverName, QObject *parent = 0);
40 virtual ~QWebSocketServer();
42 bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
45 bool isListening() const;
47 void setMaxPendingConnections(int numConnections);
48 int maxPendingConnections() const;
50 quint16 serverPort() const;
51 QHostAddress serverAddress() const;
53 bool setSocketDescriptor(int socketDescriptor);
54 int socketDescriptor() const;
56 bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
57 bool hasPendingConnections() const;
58 virtual QWebSocket *nextPendingConnection();
60 QAbstractSocket::SocketError serverError() const;
61 QString errorString() const;
63 void pauseAccepting();
64 void resumeAccepting();
66 #ifndef QT_NO_NETWORKPROXY
67 void setProxy(const QNetworkProxy &networkProxy);
68 QNetworkProxy proxy() const;
71 QList<QWebSocketProtocol::Version> supportedVersions() const;
72 QList<QString> supportedProtocols() const;
73 QList<QString> supportedExtensions() const;
76 virtual bool isOriginAllowed(const QString &origin) const;
79 void acceptError(QAbstractSocket::SocketError socketError);
83 Q_DISABLE_COPY(QWebSocketServer)
84 QWebSocketServerPrivate * const d_ptr;
85 friend class QWebSocketServerPrivate;
90 #endif // QWEBSOCKETSERVER_H