diff options
author | Justin Dickow <jjdickow@gmail.com> | 2014-03-18 13:46:46 -0400 |
---|---|---|
committer | Justin Dickow <jjdickow@gmail.com> | 2014-03-18 13:46:46 -0400 |
commit | ba492fb83c258bc60ca68120ce964a95b41133b5 (patch) | |
tree | af99c087941d65a19831397c1ec5eb34850cfc7f /SDL_Core/src/components/qt_hmi/References/Work/fordsdlcore/QtWebsocket/QWsServer.h | |
parent | 8504605b01177da2e55bee6abe4c3f20c82da379 (diff) | |
download | smartdevicelink-ba492fb83c258bc60ca68120ce964a95b41133b5.tar.gz |
initial commit for API 3.0 (replaced all)
Diffstat (limited to 'SDL_Core/src/components/qt_hmi/References/Work/fordsdlcore/QtWebsocket/QWsServer.h')
-rw-r--r-- | SDL_Core/src/components/qt_hmi/References/Work/fordsdlcore/QtWebsocket/QWsServer.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/SDL_Core/src/components/qt_hmi/References/Work/fordsdlcore/QtWebsocket/QWsServer.h b/SDL_Core/src/components/qt_hmi/References/Work/fordsdlcore/QtWebsocket/QWsServer.h new file mode 100644 index 000000000..c526c747a --- /dev/null +++ b/SDL_Core/src/components/qt_hmi/References/Work/fordsdlcore/QtWebsocket/QWsServer.h @@ -0,0 +1,87 @@ +#ifndef QWSSERVER_H +#define QWSSERVER_H + +#include <QTcpServer> +#include <QTcpSocket> +#include <QNetworkProxy> +#include <QString> +#include <QStringList> +#include <QMap> +#include <QQueue> + +#include "QWsSocket.h" + +class QWsServer : public QObject +{ + Q_OBJECT + +public: + // ctor + QWsServer(QObject * parent = 0); + // dtor + virtual ~QWsServer(); + + // public functions + void close(); + QString errorString(); + bool hasPendingConnections(); + bool isListening(); + bool listen(const QHostAddress & address = QHostAddress::Any, quint16 port = 0); + int maxPendingConnections(); + virtual QWsSocket * nextPendingConnection(); + QNetworkProxy proxy(); + QHostAddress serverAddress(); + QAbstractSocket::SocketError serverError(); + quint16 serverPort(); + void setMaxPendingConnections( int numConnections ); + void setProxy( const QNetworkProxy & networkProxy ); + bool setSocketDescriptor( int socketDescriptor ); + int socketDescriptor(); + bool waitForNewConnection( int msec = 0, bool * timedOut = 0 ); + +signals: + void newConnection(); + +protected: + // protected functions + void addPendingConnection( QWsSocket * socket ); + virtual void incomingConnection( int socketDescriptor ); + +private slots: + // private slots + void newTcpConnection(); + void closeTcpConnection(); + void dataReceived(); + +private: + // private attributes + QTcpServer * tcpServer; + QQueue<QWsSocket*> pendingConnections; + QMap<const QTcpSocket*, QStringList> headerBuffer; + +public: + // public static functions + static QByteArray serializeInt( quint32 number, quint8 nbBytes = 4 ); + static QString computeAcceptV0( QString key1, QString key2, QString thirdPart ); + static QString computeAcceptV4( QString key ); + static QString generateNonce(); + static QString composeOpeningHandshakeResponseV0( QString accept, QString origin, QString hostAddress, QString hostPort, QString resourceName, QString protocol = "" ); + static QString composeOpeningHandshakeResponseV4( QString accept, QString nonce, QString protocol = "", QString extensions = "" ); + static QString composeOpeningHandshakeResponseV6( QString accept, QString protocol = "", QString extensions = "" ); + static QString composeBadRequestResponse( QList<EWebsocketVersion> versions = QList<EWebsocketVersion>() ); + + // public static vars + static const QString regExpResourceNameStr; + static const QString regExpHostStr; + static const QString regExpKeyStr; + static const QString regExpKey1Str; + static const QString regExpKey2Str; + static const QString regExpKey3Str; + static const QString regExpVersionStr; + static const QString regExpOriginStr; + static const QString regExpOrigin2Str; + static const QString regExpProtocolStr; + static const QString regExpExtensionsStr; +}; + +#endif // QWSSERVER_H |