Renamed source directory to src (to be in line with Qt)
[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 #include <QObject>
11 #include <QQueue>
12 #include <QString>
13 #include <QHostAddress>
14 #include "qwebsocket.h"
15
16 class QTcpServer;
17 class QWebSocketServer;
18
19 class QWebSocketServerPrivate : public QObject
20 {
21         Q_OBJECT
22
23 public:
24         explicit QWebSocketServerPrivate(const QString &serverName, QWebSocketServer * const pWebSocketServer, QObject *parent = 0);
25         virtual ~QWebSocketServerPrivate();
26
27         void close();
28         QString errorString() const;
29         bool hasPendingConnections() const;
30         bool isListening() const;
31         bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
32         int maxPendingConnections() const;
33         virtual QWebSocket *nextPendingConnection();
34         QNetworkProxy proxy() const;
35         QHostAddress serverAddress() const;
36         QAbstractSocket::SocketError serverError() const;
37         quint16 serverPort() const;
38         void setMaxPendingConnections(int numConnections);
39         void setProxy(const QNetworkProxy &networkProxy);
40         bool setSocketDescriptor(int socketDescriptor);
41         int socketDescriptor() const;
42         bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
43
44         QList<QWebSocketProtocol::Version> supportedVersions() const;
45         QList<QString> supportedProtocols() const;
46         QList<QString> supportedExtensions() const;
47
48 Q_SIGNALS:
49         void newConnection();
50
51 private Q_SLOTS:
52         void onNewConnection();
53         void onCloseConnection();
54         void handshakeReceived();
55
56 private:
57         QWebSocketServer * const q_ptr;
58
59         QTcpServer *m_pTcpServer;
60         QString m_serverName;
61         QQueue<QWebSocket *> m_pendingConnections;
62
63         void addPendingConnection(QWebSocket *pWebSocket);
64 };
65
66 #endif // QWEBSOCKETSERVER_P_H