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
19 #ifndef QWEBSOCKETSERVER_H
20 #define QWEBSOCKETSERVER_H
24 #include <QHostAddress>
25 #include "qwebsocketsglobal.h"
26 #include "qwebsocketprotocol.h"
30 class QWebSocketServerPrivate;
33 class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject
38 explicit QWebSocketServer(const QString &serverName, QObject *parent = 0);
39 virtual ~QWebSocketServer();
41 bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
44 bool isListening() const;
46 void setMaxPendingConnections(int numConnections);
47 int maxPendingConnections() const;
49 quint16 serverPort() const;
50 QHostAddress serverAddress() const;
52 bool setSocketDescriptor(int socketDescriptor);
53 int socketDescriptor() const;
55 bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
56 bool hasPendingConnections() const;
57 virtual QWebSocket *nextPendingConnection();
59 QAbstractSocket::SocketError serverError() const;
60 QString errorString() const;
62 void pauseAccepting();
63 void resumeAccepting();
65 #ifndef QT_NO_NETWORKPROXY
66 void setProxy(const QNetworkProxy &networkProxy);
67 QNetworkProxy proxy() const;
70 QList<QWebSocketProtocol::Version> supportedVersions() const;
71 QList<QString> supportedProtocols() const;
72 QList<QString> supportedExtensions() const;
75 virtual bool isOriginAllowed(const QString &origin) const;
78 void acceptError(QAbstractSocket::SocketError socketError);
82 Q_DISABLE_COPY(QWebSocketServer)
83 QWebSocketServerPrivate * const d_ptr;
84 friend class QWebSocketServerPrivate;
89 #endif // QWEBSOCKETSERVER_H