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"
16 class QWebSocketServerPrivate;
19 class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject
24 explicit QWebSocketServer(const QString &serverName, QObject *parent = 0);
25 virtual ~QWebSocketServer();
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);
44 QList<QWebSocketProtocol::Version> supportedVersions() const;
45 QList<QString> supportedProtocols() const;
46 QList<QString> supportedExtensions() const;
49 virtual bool isOriginAllowed(const QString &origin) const;
55 Q_DISABLE_COPY(QWebSocketServer)
56 QWebSocketServerPrivate * const d_ptr;
57 friend class QWebSocketServerPrivate;
60 #endif // QWEBSOCKETSERVER_H