Workflow: Monitoring Presence by Using the Oracle Radio WebSocket API

Subscribe the WebSocket connection to Radio presence changes and combine the event stream with a current presence snapshot.

Before You Begin

Open an authenticated WebSocket connection for an enabled Radio user. Presence results and updates are limited to Radio users in the authenticated user's Identity Domain.

Get and Monitor Presence

  1. Follow Subscribing to Oracle Radio WebSocket Presence Updates to send SUBSCRIBE_PRESENCE.

    {
      "type": "SUBSCRIBE_PRESENCE"
    }
  2. Wait for PRESENCE_SUBSCRIBED. Record the returned domain when it is present, and begin retaining each PRESENCE_UPDATE event in the order that the connection receives it.

  3. Follow Getting Oracle Radio WebSocket Presence to send GET_PRESENCE. Supply userId to request one user's presence, or omit it to list online users visible in the Identity Domain.

    {
      "type": "GET_PRESENCE"
    }
  4. While the snapshot request is pending, continue retaining PRESENCE_UPDATE events. Use PRESENCE as the baseline for one supplied user identifier. Use PRESENCE_LIST as the online-user baseline when userId is omitted.

  5. After installing the baseline, apply the retained PRESENCE_UPDATE events in receive order. Then apply each new event to its matching userId. An event can report online, offline, or away. Its optional channel is a representative current channel, not a complete membership list.

  6. For each channel in affectedChannels that your client displays and is authorized to access, refresh the user list with LIST_CHANNEL_USERS. An empty array requires no channel-list refresh. A user can leave one channel while remaining online through another session.

Handle Missing Updates and Reconnects