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.
Currently
receive()silently discards pong frames: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
MessageTypeenum already has.pongdefined — it just needs to fall through to areturninstead ofcontinue.Callers that don't care about pongs can simply ignore them:
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.