mirror of
https://codeberg.org/steam-vent/chat.git
synced 2026-11-30 12:40:52 +01:00
update to steam-vent 0.6
This commit is contained in:
parent
e89a7da94a
commit
6f49aa5798
4 changed files with 387 additions and 53 deletions
10
src/lib.rs
10
src/lib.rs
|
|
@ -1,4 +1,4 @@
|
|||
use steam_vent::{Connection, ConnectionTrait, NetworkError};
|
||||
use steam_vent_core::ConnectionTrait;
|
||||
use steam_vent_proto::steammessages_friendmessages_steamclient::{
|
||||
CFriendMessages_IncomingMessage_Notification, CFriendMessages_SendMessage_Request,
|
||||
};
|
||||
|
|
@ -7,18 +7,18 @@ use thiserror::Error;
|
|||
use tokio_stream::{Stream, StreamExt};
|
||||
|
||||
/// High level wrapper around steam-vent's [`Connection`] for implementing a chat client
|
||||
pub struct ChatClient {
|
||||
pub struct ChatClient<Connection: ConnectionTrait> {
|
||||
connection: Connection,
|
||||
}
|
||||
|
||||
impl ChatClient {
|
||||
impl<Connection: ConnectionTrait> ChatClient<Connection> {
|
||||
/// Create a chat client from a [`Connection`]
|
||||
pub fn new(connection: Connection) -> Self {
|
||||
ChatClient { connection }
|
||||
}
|
||||
|
||||
/// Listen for incoming events
|
||||
pub fn listen(&self) -> impl Stream<Item = Result<ChatEvent, NetworkError>> + 'static {
|
||||
pub fn listen(&self) -> impl Stream<Item = Result<ChatEvent, Connection::Error>> + 'static {
|
||||
self.connection
|
||||
.on_notification::<CFriendMessages_IncomingMessage_Notification>()
|
||||
.filter_map(|notification| {
|
||||
|
|
@ -33,7 +33,7 @@ impl ChatClient {
|
|||
&self,
|
||||
target: SteamID,
|
||||
message: String,
|
||||
) -> Result<MessageResult, NetworkError> {
|
||||
) -> Result<MessageResult, Connection::Error> {
|
||||
let req = CFriendMessages_SendMessage_Request {
|
||||
steamid: Some(target.into()),
|
||||
message: Some(message),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue