Skip to content

Connection heartbeat #85

@jwoertink

Description

@jwoertink

We have this WebSocketPinger that pings the client every 3 seconds, but there's not really a way on the backend to know that things are still alive. I have a case where when a user joins a chat, we add their ID to an array, and when they leave, we remove their ID from that array. There's an edge case though where they join on desktop, then join on mobile, then leave desktop and now their ID is no longer in the array. This is a tricky problem to solve with how our app works. What would be nice is when the ping happens, we can see they're still in chat and just re-add them to the array.

To do this, I think instead of passing the socket in to the pinger, we just pass the connection. The connection has access to the socket and can still send the message, but then we can also call a method on the connection like ping. If you override this method in your connection class, you'll receive that ping on the backend too. And it shouldn't be a breaking change since the logic will all be the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions