A lightweight RFC 6455 (Web Socket) implementation for Qt5 & Qt6 by Calin Culianu [email protected]
Key highlights
- Supports both
ws://
andwss://
Web Sockets. - Support both client-side and server-side mode of operation.
- Easy to integrate: just copy
WebSocket.h
andWebSocket.cpp
into your project - Easy to use with existing codebases:
- Unlike the
QWebSocket
module from Qt, this code's main class,WebSocket::Wrapper
inherits fromQTcpSocket
and thus can easily be integrated into existing code. - In other words, the key paradigm offered is basically a generic wrapper for a regular
QTcpSocket
that itself inherits fromQTcpSocket
.
- Unlike the
- Asynchronous mode of operation (requires an event loop in the thread the
WebSocket::Wrapper
lives in). - Requires C++17.
How to use in your project
- Copy
WebSocket.h
andWebSocket.cpp
into your project. - Enjoy! (The license here is MIT so you can use this in any project, commercial or open source).
What's new in v1.2.2
- Updated the code to compile out of the box with Qt6.
- All of the code code in
WebSocket.cpp
andWebSocket.h
was Qt6-ready already, since it relied on low-level classes from Qt5 which are almost identical in Qt6 - The only change: updating the test app:
TestEchoClientServer.cpp
to useQRegularExpression
(present in Qt5 and Qt6), rather than the deprecatedQRegExp
- All of the code code in