There are a few ways you could approach detecting user status in real-time with Broadcast:
Use the presence state to track which users are currently connected. When a user joins a channel, you can update their presence to online. And when they leave or disconnect, you can update it to offline. This gives you a real-time view of who is currently active. Use the Echo.join callback to send an API request when a user joins a channel, setting their status to online. And use the Echo.leave callback to send a request when they leave, setting them to offline. This avoids multiple requests on leave. Send a periodic "heartbeat" event from the client that updates a "last seen" timestamp for the user. If you don't receive the event after a certain timeout, you can assume the user disconnected. On the server, track individual channel connections and send disconnect events when a connection is closed for a specific user. This avoids relying on presence or client events. So in summary, presence, join/leave callbacks, heartbeats, and server-side disconnection events are some ways to detect real-time user status with Broadcast. Using a combination of these approaches is likely the most robust.