2 * @file websocketserver.h
3 * @author Kurt Pattyn (pattyn.kurt@gmail.com)
4 * @brief Defines the WebSocketServer class.
7 #ifndef QWEBSOCKETSERVER_H
8 #define QWEBSOCKETSERVER_H
12 #include <QHostAddress>
13 #include "qwebsocketsglobal.h"
14 #include "qwebsocketprotocol.h"
18 class QWebSocketServerPrivate;
21 class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject
26 explicit QWebSocketServer(const QString &serverName, QObject *parent = 0);
27 virtual ~QWebSocketServer();
30 QString errorString() const;
31 bool hasPendingConnections() const;
32 bool isListening() const;
33 bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
34 int maxPendingConnections() const;
35 virtual QWebSocket *nextPendingConnection();
36 QNetworkProxy proxy() const;
37 QHostAddress serverAddress() const;
38 QAbstractSocket::SocketError serverError() const;
39 quint16 serverPort() const;
40 void setMaxPendingConnections(int numConnections);
41 void setProxy(const QNetworkProxy &networkProxy);
42 bool setSocketDescriptor(int socketDescriptor);
43 int socketDescriptor() const;
44 bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
45 #ifndef QT_NO_NETWORKPROXY
46 void setProxy(const QNetworkProxy &networkProxy);
47 QNetworkProxy proxy() const;
50 QList<QWebSocketProtocol::Version> supportedVersions() const;
51 QList<QString> supportedProtocols() const;
52 QList<QString> supportedExtensions() const;
55 virtual bool isOriginAllowed(const QString &origin) const;
58 void acceptError(QAbstractSocket::SocketError socketError);
62 Q_DISABLE_COPY(QWebSocketServer)
63 QWebSocketServerPrivate * const d_ptr;
64 friend class QWebSocketServerPrivate;
69 #endif // QWEBSOCKETSERVER_H