Disclaimer: This is not an official Kwai product.
免责声明: 这不是快手的官方项目
一个异步的,更符合人体工学的 快手互动直播 Rust SDK
(目标是更优雅的接口设计,所以在1.0.0之前,不保证向前兼容性)
用法特别简单
引入依赖
toml
[dependencies]
kwai_interactive_live = "*"
建立连接, 并返回一个异步流
```rust use kwaiinteractivelive::*;
let p = ConnectParams { host: "xxxxxxx.com".tostring(), appid: "appid".tostring(), code: "code".tostring(), ..Default::default() }; let (connectresp, stream) = connect(p).await?; stream.for_each(|event| async move { 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?; ```