WebSocketServer QML Type
QWebSocketServer 的 QML 接口。更多
| Import Statement: | import QtWebSockets 1.11 |
属性
- accept : bool
- errorString : string
- host : string
- listen : bool
- name : string
- port : int
- supportedSubprotocols : list<string>
(since 6.4) - url : url
信号
- clientConnected(WebSocket webSocket)
详细说明
财产文件
accept : bool
设为 true 时,服务器监听时接受传入的客户端连接。设为 false 时,将拒绝传入连接。默认情况下,接受连接。
errorString : string [read-only]
发生错误时的字符串化错误信息。
host : string
服务器的主机地址。默认使用 localhost。
listen : bool
当服务器应该监听客户端连接时设置为 true,否则设置为 false。设置为 "true "时,服务器将监听由主机和端口定义的指定 url。否则服务器将关闭。默认情况下,服务器不监听。
name : string
在 http 握手阶段使用的服务器名称。
port : int
服务器正在监听的端口。该值范围必须在 0-65535 之间。
默认情况下,端口会自动选择。
supportedSubprotocols : list<string> [since 6.4]
服务器支持的协议列表。
该属性在 Qt 6.4 中引入。
url : url [read-only]
客户端 WebSockets 可以连接的服务器网址。该网址使用ws://方案,包括服务器监听的端口和服务器的主机地址。
信号文档
clientConnected(WebSocket webSocket)
webSocket 是新创建的WebSocket 。
注: 相应的处理程序是onClientConnected 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.