Function twitch_api2::pubsub::unlisten_command
source · [−]pub fn unlisten_command<'t, O>(
topics: &'t [Topics],
nonce: O
) -> Result<String, Error> where
O: Into<Option<&'t str>>,
Available on crate feature
pubsub
only.Expand description
Create a unlisten command.
Examples
Unlisten from moderator actions and follows
// These are the exact same topics as for the `listen_command`.
let chat_mod_actions = pubsub::moderation::ChatModeratorActions {
user_id: 4321,
channel_id: 1234,
}
.into_topic();
let follows = pubsub::following::Following { channel_id: 1234 }.into_topic();
// Create the command to send to twitch
let command = pubsub::unlisten_command(
&[chat_mod_actions, follows],
// This does not need to be the same nonce that was sent for listening.
// The nonce is only there to identify the payload and the response.
"super se3re7 random string",
)
.expect("serializing failed");
// Send the message with your favorite websocket client
send_command(command).unwrap();
// To parse the websocket messages, use pubsub::Response::parse