QML 웹소켓 클라이언트

QML WebSocket 클라이언트 예제를 작성하는 방법을 설명합니다.

QML WebSocket 클라이언트 예제는 QML API를 사용하여 에코 서버에 대한 보안 및 비보안 WebSocket 연결을 만들고, 연결 열기와 닫기를 번갈아 가며 수행합니다. 연결이 열릴 때마다 메시지를 보냅니다.

QML WebSocket Client GUI

이 예에서는 환영 메시지가 있는 창을 엽니다. 창을 클릭할 때마다 외부 에코 서버에 대한 두 개의 연결이 열리고 닫히는 것을 번갈아 가며 나타납니다. 사용된 에코 서버는 ws.ifelse.io에 있으며 이 예제가 작동하려면 인터넷 연결이 필요합니다. 또한 보안 연결이 작동하려면 TLS를 사용하도록 설정해야 합니다. 연결이 열리거나 닫히면 onStatusChanged 핸들러가 statusChanged 신호를 처리합니다. 소켓이 열릴 때마다 메시지가 전송되고, 소켓이 닫힐 때마다 창에 메시지가 기록됩니다. 또한 서버에서 받은 메시지를 창에 기록하는 onTextMessageReceived 핸들러가 있습니다.

예제 프로젝트 @ code.qt.io

© 2025 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.