session.unsubscribe commandThe session.unsubscribe command of the session module cancels event subscriptions previously registered with session.subscribe, either by subscription ID or by event name.
/* Using event name */
{
"method": "session.unsubscribe",
"params": {
"events": ["log.entryAdded"]
}
}
/* Using subscription ID */
{
"method": "session.unsubscribe",
"params": {
"subscriptions": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890"]
}
}The params field contains one of the following fields:
eventsAn array of one or more strings that specifies event names for canceling subscriptions. Each string can be either a specific event name (for example, "log.entryAdded") or a module name (for example, "log") that unsubscribes the client from all events in that module. Only global subscriptions can be removed using event names; those created using contexts or userContexts cannot be.
subscriptionsAn array of one or more subscription IDs that specifies the subscriptions to cancel, including both global and context-scoped subscriptions.
The result field in the response is an empty object ({}).
invalid argumentWhen unsubscribing using IDs, a subscription ID is not found. When unsubscribing using event names, the events array is empty or omitted, or an event name does not match any active global subscription.
With an active subscription, send the following message to cancel it by ID:
{
"id": 3,
"method": "session.unsubscribe",
"params": {
"subscriptions": ["c7b7b3a2-1f4b-4b4e-8a1f-2a3b4c5d6e7f"]
}
}After successfully unsubscribing, the browser responds as follows:
{
"id": 3,
"type": "success",
"result": {}
}With a global subscription to log.entryAdded active, send the following message to stop receiving that event:
{
"id": 4,
"method": "session.unsubscribe",
"params": {
"events": ["log.entryAdded"]
}
}After successfully unsubscribing, the browser responds as follows:
{
"id": 4,
"type": "success",
"result": {}
}With global subscriptions active, send the following message to unsubscribe from all events in the log module and a specific event from the network module:
{
"id": 5,
"method": "session.unsubscribe",
"params": {
"events": ["log", "network.beforeRequestSent"]
}
}After successfully unsubscribing, the browser responds as follows:
{
"id": 5,
"type": "success",
"result": {}
}session.subscribe commandsession.new commandsession.end command