Added missing functionality after a comparison between QWebSocket and QTcpSocket...
[contrib/qtwebsockets.git] / src / qwebsocketserver_p.h
1 /**
2  * @file websocketserver_p.h
3  * @author Kurt Pattyn (pattyn.kurt@gmail.com)
4  * @brief Defines the private WebSocketServerPrivate class.
5  */
6
7 #ifndef QWEBSOCKETSERVER_P_H
8 #define QWEBSOCKETSERVER_P_H
9 //
10 //  W A R N I N G
11 //  -------------
12 //
13 // This file is not part of the Qt API.  It exists purely as an
14 // implementation detail.  This header file may change from version to
15 // version without notice, or even be removed.
16 //
17 // We mean it.
18 //
19
20 #include <QObject>
21 #include <QQueue>
22 #include <QString>
23 #include <QHostAddress>
24 #include "qwebsocket.h"
25
26 QT_BEGIN_NAMESPACE
27
28 class QTcpServer;
29 class QWebSocketServer;
30
31 class QWebSocketServerPrivate : public QObject
32 {
33         Q_OBJECT
34
35 public:
36         explicit QWebSocketServerPrivate(const QString &serverName, QWebSocketServer * const pWebSocketServer, QObject *parent = 0);
37         virtual ~QWebSocketServerPrivate();
38
39         void close();
40         QString errorString() const;
41         bool hasPendingConnections() const;
42         bool isListening() const;
43         bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
44         int maxPendingConnections() const;
45         virtual QWebSocket *nextPendingConnection();
46         void pauseAccepting();
47 #ifndef QT_NO_NETWORKPROXY
48         QNetworkProxy proxy() const;
49         void setProxy(const QNetworkProxy &networkProxy);
50 #endif
51         void resumeAccepting();
52         QHostAddress serverAddress() const;
53         QAbstractSocket::SocketError serverError() const;
54         quint16 serverPort() const;
55         void setMaxPendingConnections(int numConnections);
56         bool setSocketDescriptor(int socketDescriptor);
57         int socketDescriptor() const;
58         bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
59
60         QList<QWebSocketProtocol::Version> supportedVersions() const;
61         QList<QString> supportedProtocols() const;
62         QList<QString> supportedExtensions() const;
63
64 Q_SIGNALS:
65         void newConnection();
66
67 private Q_SLOTS:
68         void onNewConnection();
69         void onCloseConnection();
70         void handshakeReceived();
71
72 private:
73         QWebSocketServer * const q_ptr;
74
75         QTcpServer *m_pTcpServer;
76         QString m_serverName;
77         QQueue<QWebSocket *> m_pendingConnections;
78
79         void addPendingConnection(QWebSocket *pWebSocket);
80 };
81
82 QT_END_NAMESPACE
83
84 #endif // QWEBSOCKETSERVER_P_H