[−][src]Module misskey::streaming
Streaming API.
Example
Stream the notes in the local timeline:
use futures::stream::StreamExt; use misskey::streaming::channel::local_timeline::{self, LocalTimelineEvent}; // Connect to the local timeline channel. let mut stream = client.channel(local_timeline::Request::default()).await?; loop { // Wait for the next note using `next` method from `StreamExt`. let LocalTimelineEvent::Note(note) = stream.next().await.unwrap()?; println!("{:?}", note); }
Capture the note:
use futures::stream::StreamExt; use misskey::model::{note::Note, id::Id}; use misskey::streaming::note::NoteUpdateEvent; let mut stream = client.subnote("NOTE_ID_TO_WATCH").await?; loop { // Wait for the event note using `next` method from `StreamExt`. let event = stream.next().await.unwrap()?; match event { NoteUpdateEvent::Reacted { reaction, user_id } => { println!("{:?} added {:?}", user_id, reaction); } NoteUpdateEvent::Unreacted { reaction, user_id } => { println!("{:?} removed {:?}", user_id, reaction); } NoteUpdateEvent::Deleted { deleted_at } => { println!("deleted at {:?}", deleted_at); } NoteUpdateEvent::PollVoted { choice, user_id } => { println!("{:?} voted to {}", user_id, choice); } } }
Monitor newly added emojis:
use futures::stream::StreamExt; use misskey::streaming::emoji::EmojiAddedEvent; // Connect to the broadcast stream. let mut stream = client.broadcast::<EmojiAddedEvent>().await?; loop { let emoji = stream.next().await.unwrap()?.emoji; println!("Emoji {} is added", emoji.name); }
Re-exports
pub use misskey_api::streaming::*; |
Traits
BroadcastEvent | Events you receive from broadcast stream. |
ConnectChannelRequest | Request to connect to the channel. |
StreamSink | |
StreamingClient | Abstraction over API clients with streaming connections. |
SubNoteEvent | Events you receive with a subscription to the note. |
Type Definitions
BoxStreamSink | An owned dynamically typed |
BroadcastStream | Stream for the |
ChannelStream | Stream for the |
SubNoteStream | Stream for the |