Unsubscribing an Oracle Radio User from WebSocket Channels

Send an UNSUBSCRIBE_USER message to remove another connected Radio user from one or more live channel subscriptions.

Permissions and Prerequisites

The following permissions and prerequisites apply to this operation.

RequirementValue
AuthenticationComplete the supported authentication path for the client before sending this operation. See authentication.
Radio permissionradio.user.subscriptions.manage
Channel accessThis operation changes the target user's live channel subscription. It doesn't change the target user's channel access.
Session stateThe requester's WebSocket connection must be open. The target username must identify a currently connected Radio user in the same Identity Domain.

Request

Send the UNSUBSCRIBE_USER message as a JSON text message.

NameData typeRequiredDefaultConstraintsDescription
typestringYesNoneMust be UNSUBSCRIBE_USER.Identifies the user-unsubscription operation.
targetUserstringConditionalNoneAt least one of targetUser or user is required.Username of the user to unsubscribe. Use this property for new integrations.
userstringConditionalNoneAt least one of targetUser or user is required.Legacy alias for targetUser.
channelstringConditionalNoneAt least one of channel or channels is required.One channel name.
channelsarray of stringsConditionalNoneAt least one of channel or channels is required.Channel names. Use this property to unsubscribe the user from one or more channels.

The request must include at least one target selector and at least one channel selector. Use targetUser instead of the legacy user alias. Specify channel for one channel or channels for one or more channels.

{
  "type": "UNSUBSCRIBE_USER",
  "targetUser": "field-unit-5",
  "channels": [
    "emergency"
  ]
}

Responses

The following table lists the messages the client can receive and explains their purpose.

Message typeKindDescription
USER_UNSUBSCRIBEDDirect responseReturns the unsubscription result for each requested channel.
UNSUBSCRIBED_BYAsynchronous eventNotifies the target user's connection that another user unsubscribed it from a channel.
ERRORDenial or errorIndicates a missing target or channel selector, a missing management permission, a target user who isn't connected, or another processing failure.

USER_UNSUBSCRIBED Response

The following table describes the response properties, their data types, and whether they are required.

NameData typeRequiredDescription
typestringYesResponse type. The value is USER_UNSUBSCRIBED.
targetUserstringYesUsername of the target user.
channelsobjectYesMap keyed by channel name. Each value describes the channel unsubscription result.
channels.*.unsubscribedbooleanYesWhether the target user was unsubscribed from the channel.
channels.*.clientsUnsubscribedintegerNoNumber of the target user's connected clients unsubscribed from the channel.
channels.*.reasonstringNoReason that a channel subscription wasn't removed.
unsubscribedBystringNoUsername of the user who requested the unsubscription.
{
  "type": "USER_UNSUBSCRIBED",
  "targetUser": "field-unit-5",
  "channels": {
    "emergency": {
      "unsubscribed": true,
      "clientsUnsubscribed": 1
    }
  },
  "unsubscribedBy": "dispatcher1"
}

UNSUBSCRIBED_BY Event

The following table describes the event properties, their data types, and whether they are required.

NameData typeRequiredDescription
typestringYesEvent type. The value is UNSUBSCRIBED_BY.
channelstringYesChannel from which the target user's connection was unsubscribed.
unsubscribedBystringYesUsername of the user who requested the unsubscription.
messagestringYesNotification message.
{
  "type": "UNSUBSCRIBED_BY",
  "channel": "emergency",
  "unsubscribedBy": "dispatcher1",
  "message": "You have been unsubscribed from channel 'emergency' by dispatcher1"
}