diff --git a/lib/src/connection.rs b/lib/src/connection.rs index a17c951..416d780 100644 --- a/lib/src/connection.rs +++ b/lib/src/connection.rs @@ -13,7 +13,6 @@ use async_tungstenite::{ tungstenite, WebSocketStream, }; use futures::{SinkExt as _, StreamExt}; -use serde::Deserialize; use snafu::prelude::*; use tokio::sync::broadcast; use vapore_proto::{ @@ -31,7 +30,7 @@ use crate::{ const CHANNEL_CAPACITY: usize = 16; #[derive(Clone)] -struct SessionInner { +struct CMSessionInner { /// Steam ID of current user. When set to None we are not logged in steam_id: Option, /// Realm we're connecting to. AIUI this corresponds to account universe. @@ -56,12 +55,16 @@ struct SessionInner { subscribe_senders: HashMap>, } -impl SessionInner { - pub fn alloc_jobid(&mut self) -> u64 { +impl CMSessionInner { + /// Create a new job ID. + /// Officially there's some complicated format for this, + /// but we're using random for now + fn alloc_jobid(&mut self) -> u64 { rand::random() } - pub fn wake_sender(&mut self) { + /// Wake the send thread, use after adding messages to the send queue + fn wake_sender(&mut self) { if let Some(waker) = self.send_waker.take() { waker.wake() } @@ -70,7 +73,7 @@ impl SessionInner { struct Context { socket: WebSocketStream, - session: Arc>, + session: Arc>, } impl Context { @@ -191,9 +194,13 @@ impl Future for Context { } } +/// A low-level connection to a Valve Connection Manager server. +/// You can use it to send requests, call RPC functions, +/// and subscribe to message types, but it will not keep a record +/// of data recieved. #[derive(Clone)] pub struct CMSession { - inner: Arc>, + inner: Arc>, } impl CMSession { @@ -204,7 +211,7 @@ impl CMSession { url: server.to_string(), })?; - let inner = SessionInner { + let inner = CMSessionInner { steam_id: None, realm: 1, client_session_id: 0,