pub fn listen_command<'t, T, N>(
    topics: &'t [Topics],
    auth_token: T,
    nonce: N
) -> Result<String, Error>where
    T: Into<Option<&'t str>>,
    N: Into<Option<&'t str>>,
Available on crate feature pubsub only.
Expand description

Create a listen command.

Examples

Create a listen message for moderator actions

// We want to subscribe to moderator actions on channel with id 1234
// as if we were a user with id 4321 that is moderator on the channel.
let chat_mod_actions = pubsub::moderation::ChatModeratorActions {
    user_id: 4321,
    channel_id: 1234,
}
.into_topic();

// Listen to follows as well
let follows = pubsub::following::Following { channel_id: 1234 }.into_topic();
// Create the topic command to send to twitch
let command = pubsub::listen_command(
    &[chat_mod_actions, follows],
    "authtoken",
    "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