一个异步的,高性能的,更符合人体工学的 快手互动直播 Rust SDK
(目标是更优雅的接口设计,所以在 1.0.0 之前,不保证向前兼容性)
用法特别简单
引入依赖
toml
[dependencies]
kwai_interactive_live = "*"
futures-lite = "1"
建立连接, 并返回一个异步流
```rust use kwaiinteractivelive::*; use futures_lite::stream::StreamExt;
let p = ConnectParams { host: "xxxxxxx.com".tostring(), appid: "appid".tostring(), code: "code".tostring(), ..Default::default() }; let (connectresp, stream) = connect(p).await?; stream.intostream().foreach(|event| match event { Event::Gift(gift) => log::info!("收到个礼物: {gift:?} !"), Event::Comment(comment) => log::info!("收到个弹幕: {comment:?} !"), _ => log::info!("收到其他消息: {event:?}"), }).await; ```
关闭游戏 主动断开互动连接
```rust use kwaiinteractivelive::*;
let p = DisconnectParams { host: "xxxxxxx.com".tostring(), token: "xxxxxxxxxxx".tostring() }; disconnect(&p).await?; ```
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions