2 QWebSockets implements the WebSocket protocol as defined in RFC 6455.
3 Copyright (C) 2013 Kurt Pattyn (pattyn.kurt@gmail.com)
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.
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.
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
20 #ifndef QWEBSOCKETSERVER_P_H
21 #define QWEBSOCKETSERVER_P_H
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.
36 #include <QHostAddress>
37 #include "qwebsocket.h"
42 class QWebSocketServer;
44 class QWebSocketServerPrivate : public QObject
49 explicit QWebSocketServerPrivate(const QString &serverName, QWebSocketServer * const pWebSocketServer, QObject *parent = 0);
50 virtual ~QWebSocketServerPrivate();
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);
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);
73 QList<QWebSocketProtocol::Version> supportedVersions() const;
74 QList<QString> supportedProtocols() const;
75 QList<QString> supportedExtensions() const;
77 void setServerName(const QString &serverName);
78 QString serverName() const;
84 void onNewConnection();
85 void onCloseConnection();
86 void handshakeReceived();
89 Q_DECLARE_PUBLIC(QWebSocketServer)
90 QWebSocketServer * const q_ptr;
92 QTcpServer *m_pTcpServer;
94 QQueue<QWebSocket *> m_pendingConnections;
96 void addPendingConnection(QWebSocket *pWebSocket);
101 #endif // QWEBSOCKETSERVER_P_H