2 * @file websocketserver_p.h
3 * @author Kurt Pattyn (pattyn.kurt@gmail.com)
4 * @brief Defines the private WebSocketServerPrivate class.
7 #ifndef QWEBSOCKETSERVER_P_H
8 #define QWEBSOCKETSERVER_P_H
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.
23 #include <QHostAddress>
24 #include "qwebsocket.h"
29 class QWebSocketServer;
31 class QWebSocketServerPrivate : public QObject
36 explicit QWebSocketServerPrivate(const QString &serverName, QWebSocketServer * const pWebSocketServer, QObject *parent = 0);
37 virtual ~QWebSocketServerPrivate();
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 #ifndef QT_NO_NETWORKPROXY
47 QNetworkProxy proxy() const;
48 void setProxy(const QNetworkProxy &networkProxy);
50 QHostAddress serverAddress() const;
51 QAbstractSocket::SocketError serverError() const;
52 quint16 serverPort() const;
53 void setMaxPendingConnections(int numConnections);
54 bool setSocketDescriptor(int socketDescriptor);
55 int socketDescriptor() const;
56 bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
58 QList<QWebSocketProtocol::Version> supportedVersions() const;
59 QList<QString> supportedProtocols() const;
60 QList<QString> supportedExtensions() const;
66 void onNewConnection();
67 void onCloseConnection();
68 void handshakeReceived();
71 QWebSocketServer * const q_ptr;
73 QTcpServer *m_pTcpServer;
75 QQueue<QWebSocket *> m_pendingConnections;
77 void addPendingConnection(QWebSocket *pWebSocket);
82 #endif // QWEBSOCKETSERVER_P_H