Crates.io | felgens |
lib.rs | felgens |
version | 0.3.1 |
source | src |
created_at | 2022-11-27 15:20:10.172628 |
updated_at | 2023-03-26 10:45:57.542739 |
description | Bilibili live danmu websocket library |
homepage | https://github.com/eatradish/felgens |
repository | https://github.com/eatradish/felgens |
max_upload_size | |
id | 723797 |
size | 80,552 |
Bilibili live danmu websocket library
use anyhow::Result;
use felgens::{ws_socket_object, WsStreamMessageType};
use tokio::sync::mpsc::{self, UnboundedReceiver};
#[tokio::main]
async fn main() {
let (tx, rx) = mpsc::unbounded_channel();
// bilibili live room id (true id): 22746343
let ws = ws_socket_object(tx, 22746343);
if let Err(e) = tokio::select! {v = ws => v, v = recv(rx) => v} {
eprintln!("{}", e);
}
}
async fn recv(mut rx: UnboundedReceiver<WsStreamMessageType>) -> Result<()> {
while let Some(msg) = rx.recv().await {
println!("{:?}", msg);
}
Ok(())
}
Or run cargo run --example danmu