Qt WebChannel ChatClient HTML 예제
웹소켓을 통해 QWebChannel 서버와 통신하는 HTML/JavaScript 클라이언트입니다.
ChatClient HTML은 JavaScript와 HTML을 사용하여 구현된 간단한 QWebChannel 클라이언트를 제공합니다.
예제 실행하기
예제를 실행하려면 브라우저에서 chatclient.html
파일을 엽니다.
웹 채널 클라이언트 구현하기
클라이언트는 채팅 서버에 대한 웹소켓 연결을 초기화하고 채팅 클라이언트 구현에 필요한 모든 신호, 슬롯 및 속성이 포함된 객체를 받습니다.
로그인 후 클라이언트는 sendMessage
메서드를 호출하고 newMessage
신호를 수신하여 메시지를 주고받을 수 있습니다. 또한 userList
프로퍼티는 연결된 다른 모든 클라이언트의 이름을 제공합니다. 이 목록은 내용이 변경되면 자동으로 업데이트됩니다. 또한 클라이언트는 연결이 끊긴 클라이언트를 감지하여 userList
속성에서 제거하는 데 필요한 서버의 연결 유지 신호에 응답합니다.
이 예는 신호 연결(newMessage
), 슬롯 호출(sendMessage
), 속성 변경 처리(userList
)와 같은 기본 요소를 QWebChannel 의 클라이언트 JavaScript 구현에서 어떻게 사용할 수 있는지 보여줍니다.
클라이언트는 Qt WebChannel ChatServer 예제로 작업할 수 있습니다.
Qt WebChannel ChatServer 예제 및 Qt WebChannel ChatClient QML 애플리케이션도참조하세요 .
© 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.