daemon: session doesn't need to be mutable
This commit is contained in:
parent
277967fae9
commit
9e960d98e4
|
@ -269,7 +269,7 @@ impl CMSession {
|
|||
tokio::spawn(async move { cloned.send_heartbeat_task(interval).await });
|
||||
}
|
||||
|
||||
async fn send_heartbeat_task(mut self, interval_secs: u32) -> eyre::Result<()> {
|
||||
async fn send_heartbeat_task(self, interval_secs: u32) -> eyre::Result<()> {
|
||||
let mut interval = tokio::time::interval(time::Duration::from_secs(interval_secs as u64));
|
||||
loop {
|
||||
interval.tick().await;
|
||||
|
@ -277,18 +277,18 @@ impl CMSession {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_steam_id(&mut self, new_steam_id: u64) {
|
||||
pub fn set_steam_id(&self, new_steam_id: u64) {
|
||||
let mut inner = self.inner.lock().expect("Lock was poisoned");
|
||||
inner.steam_id = Some(new_steam_id);
|
||||
}
|
||||
|
||||
pub fn set_client_session_id(&mut self, new_client_session_id: i32) {
|
||||
pub fn set_client_session_id(&self, new_client_session_id: i32) {
|
||||
let mut inner = self.inner.lock().expect("Lock was poisoned");
|
||||
inner.client_session_id = new_client_session_id;
|
||||
}
|
||||
|
||||
pub fn call_service_method<T: protobuf::Message, U: protobuf::Message>(
|
||||
&mut self,
|
||||
&self,
|
||||
method: String,
|
||||
body: T,
|
||||
) -> CallServiceMethod<T, U> {
|
||||
|
@ -306,7 +306,7 @@ impl CMSession {
|
|||
/// Send a message without a jobid.
|
||||
/// Returns as soon as the message is in the send buffer
|
||||
pub fn send_notification<T: protobuf::Message>(
|
||||
&mut self,
|
||||
&self,
|
||||
action: EMsg,
|
||||
body: T,
|
||||
) -> eyre::Result<()> {
|
||||
|
@ -339,7 +339,7 @@ impl CMSession {
|
|||
/// Subscribe to receive a notification every time a message of a
|
||||
/// given type is received
|
||||
pub fn subscribe_message_type(
|
||||
&mut self,
|
||||
&self,
|
||||
action: EMsg,
|
||||
) -> broadcast::Receiver<CMRawProtoBufMessage> {
|
||||
let mut inner = self.inner.lock().expect("Lock was poisoned");
|
||||
|
@ -355,7 +355,7 @@ impl CMSession {
|
|||
|
||||
#[must_use = "futures do nothing unless polled"]
|
||||
pub struct CallServiceMethod<'a, T: protobuf::Message, U: protobuf::Message> {
|
||||
session: &'a mut CMSession,
|
||||
session: &'a CMSession,
|
||||
body: T,
|
||||
method: String,
|
||||
jobid: Option<u64>,
|
||||
|
|
|
@ -28,7 +28,7 @@ pub async fn main() -> eyre::Result<()> {
|
|||
let servers = connection::bootstrap_find_servers().await?;
|
||||
log::debug!("Found servers: {:?}", servers);
|
||||
|
||||
let mut session = connection::CMSession::connect(&servers[0]).await?;
|
||||
let session = connection::CMSession::connect(&servers[0]).await?;
|
||||
|
||||
session.send_notification(
|
||||
EMsg::k_EMsgClientHello,
|
||||
|
@ -97,7 +97,6 @@ pub async fn main() -> eyre::Result<()> {
|
|||
|
||||
let session_cloned = session.clone();
|
||||
let poll_handle = tokio::spawn(async move {
|
||||
let mut session = session_cloned;
|
||||
loop {
|
||||
interval.tick().await;
|
||||
let request = CAuthentication_PollAuthSessionStatus_Request {
|
||||
|
@ -106,7 +105,7 @@ pub async fn main() -> eyre::Result<()> {
|
|||
..Default::default()
|
||||
};
|
||||
let response: CMProtoBufMessage<CAuthentication_PollAuthSessionStatus_Response> =
|
||||
session
|
||||
session_cloned
|
||||
.call_service_method(
|
||||
"Authentication.PollAuthSessionStatus#1".to_string(),
|
||||
request,
|
||||
|
@ -164,7 +163,7 @@ pub async fn main() -> eyre::Result<()> {
|
|||
},
|
||||
)?;
|
||||
|
||||
let mut session_cloned = session.clone();
|
||||
let session_cloned = session.clone();
|
||||
tokio::spawn(async move {
|
||||
let license_list_raw = session_cloned
|
||||
.subscribe_message_type(EMsg::k_EMsgClientLicenseList)
|
||||
|
|
Loading…
Reference in a new issue