aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Venner <[email protected]>2021-04-01 22:04:12 +0100
committerWilliam Venner <[email protected]>2021-04-01 22:04:12 +0100
commit58636863c316ad76ea24463be9106550928d60c1 (patch)
treef2943aee376466e2c7b7a1e408c4f0cae34b0d6a
parentMerge pull request #39 from adumbidiot/remove-libc (diff)
downloadsteamworks-rs-58636863c316ad76ea24463be9106550928d60c1.tar.xz
steamworks-rs-58636863c316ad76ea24463be9106550928d60c1.zip
Add `SteamServersConnected`, `SteamServersDisconnected` and `SteamServerConnectFailure` callbacks
-rw-r--r--src/user.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/user.rs b/src/user.rs
index eb81ac3..cffdae1 100644
--- a/src/user.rs
+++ b/src/user.rs
@@ -209,6 +209,63 @@ unsafe impl Callback for ValidateAuthTicketResponse {
}
}
+/// Called when a connection to the Steam servers is made.
+#[derive(Clone, Debug)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+pub struct SteamServersConnected;
+
+unsafe impl Callback for SteamServersConnected {
+ const ID: i32 = 101;
+ const SIZE: i32 = ::std::mem::size_of::<sys::SteamServersConnected_t>() as i32;
+
+ unsafe fn from_raw(_: *mut c_void) -> Self {
+ SteamServersConnected
+ }
+}
+
+/// Called when the connection to the Steam servers is lost.
+#[derive(Clone, Debug)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+pub struct SteamServersDisconnected {
+ /// The reason we were disconnected from the Steam servers
+ pub reason: SteamError
+}
+
+unsafe impl Callback for SteamServersDisconnected {
+ const ID: i32 = 103;
+ const SIZE: i32 = ::std::mem::size_of::<sys::SteamServersDisconnected_t>() as i32;
+
+ unsafe fn from_raw(raw: *mut c_void) -> Self {
+ let val = &mut *(raw as *mut sys::SteamServersDisconnected_t);
+ SteamServersDisconnected {
+ reason: val.m_eResult.into()
+ }
+ }
+}
+
+/// Called when the connection to the Steam servers fails.
+#[derive(Clone, Debug)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+pub struct SteamServerConnectFailure {
+ /// The reason we failed to connect to the Steam servers
+ pub reason: SteamError,
+ /// Whether we are still retrying the connection.
+ pub still_retrying: bool,
+}
+
+unsafe impl Callback for SteamServerConnectFailure {
+ const ID: i32 = 102;
+ const SIZE: i32 = ::std::mem::size_of::<sys::SteamServerConnectFailure_t>() as i32;
+
+ unsafe fn from_raw(raw: *mut c_void) -> Self {
+ let val = &mut *(raw as *mut sys::SteamServerConnectFailure_t);
+ SteamServerConnectFailure {
+ reason: val.m_eResult.into(),
+ still_retrying: val.m_bStillRetrying
+ }
+ }
+}
+
/// Errors from `ValidateAuthTicketResponse`
#[derive(Debug, Error)]
pub enum AuthSessionValidateError {