Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client doesn't recognize server disconnect #108

Open
SetheenDev opened this issue Aug 15, 2022 · 1 comment
Open

Client doesn't recognize server disconnect #108

SetheenDev opened this issue Aug 15, 2022 · 1 comment

Comments

@SetheenDev
Copy link

There doesn't appear to a callback a client can register to be made aware of server disconnect. The server listen socket can definitely detect disconnected clients but not the other way around. After pulling down this crate and adding some println statements, I do see NetConnectionStatusChanged events being published to a default NetworkingSocketsData.connection_callback handler but I don't see a way to register for this outside the library.

 NetConnectionStatusChanged { connection: 791123397, connection_info: NetConnectionInfo { identity_remote: Some(steamid:765xxx..), user_data: -1, listen_socket: None, state: Ok(ProblemDetectedLocally), end_reason: Some(MiscTimeout) }, old_state: Connected }

Whether the client is connected via p2p or ip doesn't matter. Am I missing something?

@SetheenDev
Copy link
Author

SetheenDev commented Aug 19, 2022

I needed a quick and dirty solution to this. I forked, exposed some internal structs and reutilized a channel that wasn't doing anything. It's not pretty but am sharing if others stumble on this issue.

// connection health
if let Some(receiver) = connection.event_receiver.as_ref() {
    while match receiver.try_recv() {
        Ok(ev) => {
            match ev.state() {
                Ok(state) => {
                    println!("state: {:?}", state);
                    match state {
                        steamworks::networking_types::NetworkingConnectionState::None => {},
                        steamworks::networking_types::NetworkingConnectionState::Connecting => {},
                        steamworks::networking_types::NetworkingConnectionState::FindingRoute => {},
                        steamworks::networking_types::NetworkingConnectionState::Connected => {},
                        steamworks::networking_types::NetworkingConnectionState::ClosedByPeer => {},
                        steamworks::networking_types::NetworkingConnectionState::ProblemDetectedLocally => {
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant