QML 接口到 QWebSocket . 更多...
| import 语句: |
import QtWebSockets 1.10
|
(从 6.4 起)
(从 6.4 起)
(从 6.10 起)
(从 6.10 起)
(从 6.10 起)
WebSocket 是通过单 TCP 连接提供全双工通信通道的 Web 技术。WebSocket 协议由 IETF 标准化为 RFC 6455 in 2011.
|
active : bool |
When set to true, a connection is made to the server with the given url. When set to false, the connection is closed. The default value is false.
|
errorString
:
string
|
Contains a description of the last error that occurred. When no error occurrred, this string is empty.
|
negotiatedSubprotocol
:
string
|
The WebSocket subprotocol that has been negotiated with the server.
该特性在 Qt 6.4 引入。
|
requestedSubprotocols
:
list
<
string
>
|
The list of WebSocket subprotocols to send in the WebSocket handshake.
该特性在 Qt 6.4 引入。
|
status
:
Status
|
Status of the WebSocket.
The status can have the following values:
|
url : url |
Server url to connect to. The url must have one of 2 schemes: ws:// or wss:// . When not supplied, then ws:// 被使用。
|
binaryMessageReceived ( QString message ) |
This signal is emitted when a binary message is received. message contains the bytes received.
注意:
相应处理程序是
onBinaryMessageReceived
.
|
|
发射当收到先前 Ping (乒) 回复的 pong (乓) 消息时。 elapsedTime 包含往返时间 (以毫秒为单位) 而 payload 包含与 Ping (乒) 一起发送的可选负载。
注意:
相应处理程序是
onPong
.
This signal was introduced in Qt 6.10.
另请参阅 ping ().
|
statusChanged ( Status status ) |
This signal is emitted when the status of the WebSocket changes. The status argument provides the current status.
注意:
相应处理程序是
onStatusChanged
.
另请参阅 WebSocket::status .
|
textMessageReceived ( QString message ) |
This signal is emitted when a text message is received. message contains the bytes received.
注意:
相应处理程序是
onTextMessageReceived
.
|
|
|
|
Ping (乒) 服务器以指示连接仍活着。额外 payload 可以沿 Ping (乒) 消息一起发送。
大小对于 payload 不能大于 125 字节。若更大, payload 被裁剪到 125 字节。
注意: QWebSocket and QWebSocketServer 在内部处理 Ping (乒) 请求,意味着它们会自动发送回对等方的 Pong (乓) 响应。
These methods were introduced in Qt 6.10.
另请参阅 pong ().
|
void sendBinaryMessage ( ArrayBuffer message ) |
Sends the parameter message to the server.
|
void sendTextMessage ( string message ) |
发送 message to the server.