* (The \a origin is not required for non-web browser clients (see RFC 6455)).
* \note Currently only V13 (RFC 6455) is supported
*/
-QWebSocket::QWebSocket(QString origin, QWebSocketProtocol::Version version, QObject *parent) :
+QWebSocket::QWebSocket(const QString &origin, QWebSocketProtocol::Version version, QObject *parent) :
QObject(parent),
d_ptr(new QWebSocketPrivate(origin, version, this, this))
{
/*!
\brief Returns the version the socket is currently using
*/
-QWebSocketProtocol::Version QWebSocket::version()
+QWebSocketProtocol::Version QWebSocket::version() const
{
return d_ptr->version();
}
/*!
\brief Returns the name of the resource currently accessed.
*/
-QString QWebSocket::resourceName()
+QString QWebSocket::resourceName() const
{
return d_ptr->resourceName();
}
/*!
\brief Returns the url the socket is connected to or will connect to.
*/
-QUrl QWebSocket::requestUrl()
+QUrl QWebSocket::requestUrl() const
{
return d_ptr->requestUrl();
}
/*!
\brief Returns the current origin
*/
-QString QWebSocket::origin()
+QString QWebSocket::origin() const
{
return d_ptr->origin();
}
/*!
\brief Returns the currently used protocol.
*/
-QString QWebSocket::protocol()
+QString QWebSocket::protocol() const
{
return d_ptr->protocol();
}
/*!
\brief Returns the currently used extension.
*/
-QString QWebSocket::extension()
+QString QWebSocket::extension() const
{
return d_ptr->extension();
}
/*!
Returns true if the QWebSocket is valid.
*/
-bool QWebSocket::isValid()
+bool QWebSocket::isValid() const
{
return d_ptr->isValid();
}
Q_OBJECT
public:
- explicit QWebSocket(QString origin = QString(), QWebSocketProtocol::Version version = QWebSocketProtocol::V_LATEST, QObject *parent = 0);
+ explicit QWebSocket(const QString &origin = QString(), QWebSocketProtocol::Version version = QWebSocketProtocol::V_LATEST, QObject *parent = 0);
virtual ~QWebSocket();
void abort();
QAbstractSocket::SocketError error() const;
QString errorString() const;
bool flush();
- bool isValid();
+ bool isValid() const;
QHostAddress localAddress() const;
quint16 localPort() const;
QAbstractSocket::PauseModes pauseMode() const;
bool waitForConnected(int msecs = 30000);
bool waitForDisconnected(int msecs = 30000);
- QWebSocketProtocol::Version version();
- QString resourceName();
- QUrl requestUrl();
- QString origin();
- QString protocol();
- QString extension();
+ QWebSocketProtocol::Version version() const;
+ QString resourceName() const;
+ QUrl requestUrl() const;
+ QString origin() const;
+ QString protocol() const;
+ QString extension() const;
qint64 write(const char *message); //send data as text
qint64 write(const char *message, qint64 maxSize); //send data as text
/*!
\internal
*/
-QWebSocketPrivate::QWebSocketPrivate(QString origin, QWebSocketProtocol::Version version, QWebSocket *pWebSocket, QObject *parent) :
+QWebSocketPrivate::QWebSocketPrivate(const QString &origin, QWebSocketProtocol::Version version, QWebSocket *pWebSocket, QObject *parent) :
QObject(parent),
q_ptr(pWebSocket),
m_pSocket(new QTcpSocket(this)),
/*!
\internal
*/
-QWebSocketProtocol::Version QWebSocketPrivate::version()
+QWebSocketProtocol::Version QWebSocketPrivate::version() const
{
return m_version;
}
/*!
\internal
*/
-QString QWebSocketPrivate::resourceName()
+QString QWebSocketPrivate::resourceName() const
{
return m_resourceName;
}
/*!
\internal
*/
-QUrl QWebSocketPrivate::requestUrl()
+QUrl QWebSocketPrivate::requestUrl() const
{
return m_requestUrl;
}
/*!
\internal
*/
-QString QWebSocketPrivate::origin()
+QString QWebSocketPrivate::origin() const
{
return m_origin;
}
/*!
\internal
*/
-QString QWebSocketPrivate::protocol()
+QString QWebSocketPrivate::protocol() const
{
return m_protocol;
}
/*!
\internal
*/
-QString QWebSocketPrivate::extension()
+QString QWebSocketPrivate::extension() const
{
return m_extension;
}
/*!
\internal
*/
-bool QWebSocketPrivate::isValid()
+bool QWebSocketPrivate::isValid() const
{
bool valid = false;
if (m_pSocket)
Q_OBJECT
public:
- explicit QWebSocketPrivate(QString origin,
+ explicit QWebSocketPrivate(const QString &origin,
QWebSocketProtocol::Version version,
QWebSocket * const pWebSocket,
QObject *parent = 0);
QAbstractSocket::SocketError error() const;
QString errorString() const;
bool flush();
- bool isValid();
+ bool isValid() const;
QHostAddress localAddress() const;
quint16 localPort() const;
QAbstractSocket::PauseModes pauseMode() const;
bool waitForConnected(int msecs = 30000);
bool waitForDisconnected(int msecs = 30000);
- QWebSocketProtocol::Version version();
- QString resourceName();
- QUrl requestUrl();
- QString origin();
- QString protocol();
- QString extension();
+ QWebSocketProtocol::Version version() const;
+ QString resourceName() const;
+ QUrl requestUrl() const;
+ QString origin() const;
+ QString protocol() const;
+ QString extension() const;
qint64 write(const char *message); //send data as text
qint64 write(const char *message, qint64 maxSize); //send data as text
DataProcessor m_dataProcessor;
-
friend class QWebSocketServerPrivate;
friend class QWebSocket;
};