Synchronous WebSocket client implementation.
WebSocket provides a blocking WebSocket client based on the RFC 6455 protocol. Originally based on easywsclient, heavily refactored for JUCE integration. Supports both text and binary messages, ping/pong, and secure connections.
Key Features:
- WebSocket protocol (RFC 6455) implementation
- Text and binary message support
- Ping/pong keep-alive
- TLS/SSL support via SecureStreamingSocket
- Optional frame masking (required for client-to-server)
- Custom headers for authentication/protocols
Connection States:
- OPEN: Connected and ready
- CLOSING: Close handshake initiated
- CLOSED: Connection closed
Usage:
if (ws)
{
ws->send("Hello, server!");
ws->poll(100);
ws->dispatch([](const juce::MemoryBlock& data, bool isBinary) {
if (!isBinary)
{
juce::String msg = data.toString();
DBG("Received: " + msg);
}
});
ws->close();
delete ws;
}
static WebSocket * fromURL(const juce::String &url, const juce::String &origin={})
Note: This is a synchronous (blocking) implementation. For asynchronous operations with callbacks, use AsyncWebsocket instead.
- See also
- AsyncWebsocket, SecureStreamingSocket, WSHeaderType