Made accessor methods const; made serverName parameter const in QWebSocket
[contrib/qtwebsockets.git] / src / qwebsocketserver_p.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_P_H
21 #define QWEBSOCKETSERVER_P_H
22 //
23 //  W A R N I N G
24 //  -------------
25 //
26 // This file is not part of the Qt API.  It exists purely as an
27 // implementation detail.  This header file may change from version to
28 // version without notice, or even be removed.
29 //
30 // We mean it.
31 //
32
33 #include <QObject>
34 #include <QQueue>
35 #include <QString>
36 #include <QHostAddress>
37 #include "qwebsocket.h"
38
39 QT_BEGIN_NAMESPACE
40
41 class QTcpServer;
42 class QWebSocketServer;
43
44 class QWebSocketServerPrivate : public QObject
45 {
46     Q_OBJECT
47
48 public:
49     explicit QWebSocketServerPrivate(const QString &serverName, QWebSocketServer * const pWebSocketServer, QObject *parent = 0);
50     virtual ~QWebSocketServerPrivate();
51
52     void close();
53     QString errorString() const;
54     bool hasPendingConnections() const;
55     bool isListening() const;
56     bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
57     int maxPendingConnections() const;
58     virtual QWebSocket *nextPendingConnection();
59     void pauseAccepting();
60 #ifndef QT_NO_NETWORKPROXY
61     QNetworkProxy proxy() const;
62     void setProxy(const QNetworkProxy &networkProxy);
63 #endif
64     void resumeAccepting();
65     QHostAddress serverAddress() const;
66     QAbstractSocket::SocketError serverError() const;
67     quint16 serverPort() const;
68     void setMaxPendingConnections(int numConnections);
69     bool setSocketDescriptor(int socketDescriptor);
70     int socketDescriptor() const;
71     bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
72
73     QList<QWebSocketProtocol::Version> supportedVersions() const;
74     QList<QString> supportedProtocols() const;
75     QList<QString> supportedExtensions() const;
76
77 Q_SIGNALS:
78     void newConnection();
79
80 private Q_SLOTS:
81     void onNewConnection();
82     void onCloseConnection();
83     void handshakeReceived();
84
85 private:
86     QWebSocketServer * const q_ptr;
87
88     QTcpServer *m_pTcpServer;
89     QString m_serverName;
90     QQueue<QWebSocket *> m_pendingConnections;
91
92     void addPendingConnection(QWebSocket *pWebSocket);
93 };
94
95 QT_END_NAMESPACE
96
97 #endif // QWEBSOCKETSERVER_P_H