Skip to content

Expose pong frames to WebSocket callers #76

Description

@lalinsky

Currently receive() silently discards pong frames:

.pong => {
    // Ignore pong frames
    continue;
},

This makes it impossible for callers to track round-trip latency, detect that a peer responded to a ping, or implement their own connection health logic. Pong frames are valid messages that applications may want to act on.

Proposed change

Return pong frames to the caller instead of discarding them, the same way close frames are returned. The MessageType enum already has .pong defined — it just needs to fall through to a return instead of continue.

Callers that don't care about pongs can simply ignore them:

const msg = try ws.receive();
if (msg.type == .pong) continue; // or handle it

This is a small, self-contained change that unblocks callers who want to implement ping/pong health checks without the library growing an opinionated heartbeat mechanism.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wishlistSomething that would be nice to have, but not planned right now

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions