Update to fix minor compiler warnings
[contrib/qtwebsockets.git] / src / websockets / qwebsocketserver.h
1 /*
2 QWebSockets implements the WebSocket protocol as defined in RFC 6455.
3 Copyright (C) 2013 Kurt Pattyn (pattyn.kurt@gmail.com)
4
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.
9
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.
14
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
18 */
19
20 #ifndef QWEBSOCKETSERVER_H
21 #define QWEBSOCKETSERVER_H
22
23 #include <QObject>
24 #include <QString>
25 #include <QHostAddress>
26
27 #include "QtWebSockets/qwebsockets_global.h"
28 #include "QtWebSockets/qwebsocketprotocol.h"
29
30 QT_BEGIN_NAMESPACE
31
32 class QWebSocketServerPrivate;
33 class QWebSocket;
34 class QWebSocketCorsAuthenticator;
35
36 class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject
37 {
38     Q_OBJECT
39     Q_DISABLE_COPY(QWebSocketServer)
40     Q_DECLARE_PRIVATE(QWebSocketServer)
41
42 public:
43     explicit QWebSocketServer(const QString &serverName, QObject *parent = 0);
44     virtual ~QWebSocketServer();
45
46     bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
47     void close();
48
49     bool isListening() const;
50
51     void setMaxPendingConnections(int numConnections);
52     int maxPendingConnections() const;
53
54     quint16 serverPort() const;
55     QHostAddress serverAddress() const;
56
57     bool setSocketDescriptor(int socketDescriptor);
58     int socketDescriptor() const;
59
60     bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
61     bool hasPendingConnections() const;
62     virtual QWebSocket *nextPendingConnection();
63
64     QAbstractSocket::SocketError serverError() const;
65     QString errorString() const;
66
67     void pauseAccepting();
68     void resumeAccepting();
69
70     void setServerName(const QString &serverName);
71     QString serverName() const;
72
73 #ifndef QT_NO_NETWORKPROXY
74     void setProxy(const QNetworkProxy &networkProxy);
75     QNetworkProxy proxy() const;
76 #endif
77
78     QList<QWebSocketProtocol::Version> supportedVersions() const;
79     QList<QString> supportedProtocols() const;
80     QList<QString> supportedExtensions() const;
81
82 Q_SIGNALS:
83     void acceptError(QAbstractSocket::SocketError socketError);
84     void originAuthenticationRequired(QWebSocketCorsAuthenticator *pAuthenticator);
85     void newConnection();
86
87 private:
88     QWebSocketServerPrivate * const d_ptr;
89 };
90
91 QT_END_NAMESPACE
92
93 #endif // QWEBSOCKETSERVER_H