Forget
SubscriptionNo AuthStop a real-time stream by its ID. Unchanged in the New API.
No breaking changes
The
forget call works the same way on the Legacy API and the New API, so you don't need to change your code.Quick comparison
Request and response fields
Request
forget(required): the stream ID, matching^[\w-]{32,128}$. Use thesubscription.idof the stream you want to stop.passthrough(optional): data returned to you inecho_req.req_id(optional): an ID that maps the response to your request.
Response
echo_reqandmsg_type(forget): always returned.forget(optional):1means the stream stopped.0means the stream did not exist.req_id: returned when you send one.
Request structure
Legacy APIrequest example
{
"forget": "d1ee7d0d-3ca9-fbb4-720b-5312d487185b"
}New APIrequest example
{
"forget": "d1ee7d0d-3ca9-fbb4-720b-5312d487185b"
}Response structure
Legacy APIresponse example
{
"echo_req": {
"forget": "d1ee7d0d-3ca9-fbb4-720b-5312d487185b"
},
"forget": 1,
"msg_type": "forget"
}New APIresponse example
{
"echo_req": {
"forget": "d1ee7d0d-3ca9-fbb4-720b-5312d487185b"
},
"forget": 1,
"msg_type": "forget"
}Code examples
function stopStream(streamId) {
ws.send(JSON.stringify({ forget: streamId }));
}
ws.onmessage = (event) => {
const response = JSON.parse(event.data);
if (response.error) {
console.error(response.error.message);
return;
}
if (response.msg_type !== 'forget') return;
if (response.forget === 1) {
console.log('Stream stopped');
} else if (response.forget === 0) {
console.log('Stream did not exist');
} else {
console.log('No forget result returned');
}
};Any other questions? Get in touch