Skip to content

Replace WebSocket with Ktor#318

Merged
LossyDragon merged 8 commits intoLongi94:masterfrom
LossyDragon:websocket-ktor
Feb 5, 2025
Merged

Replace WebSocket with Ktor#318
LossyDragon merged 8 commits intoLongi94:masterfrom
LossyDragon:websocket-ktor

Conversation

@LossyDragon
Copy link
Collaborator

@LossyDragon LossyDragon commented Feb 5, 2025

Description

This PR replaces the kinda recent okhttp websocket approach with ktor's websocket.

The main issue with the current WSS (okhttp) handler was when steam goes down (like patch tuesdays), this would cause all sorts of issues with CMClient to reconnect or know if the disconnection was user initiated or not.
(side note: Steam doesn't broadcast when it does down on patch tuedays, the connections just so silent)

With Ktor, we're able to seperate the socket with coroutines for sending and receiving. Along with a watchdog to disconnect if a response doesnt happen within 30 seconds.

We can also have a ping/pong effect with CMsgClientHeartBeat by setting sendReply to true, keeping the watchdog at bay as it resets it's timer with every incoming message.

Thanks to @rakosi2 for painstakingly testing numerous snapshots with their project to solve this issue (hopefully)

I also noticed that processing large requests; such as many PICS requests, seem to be much faster. Not sure if this is Ktor or the WebSocket protocol for Steam, so I'll take that as a plus!

And with this, I think its time to release 1.6.0 since this was one of the long standing issues that held back the release.

Checklist

  • Code compiles correctly
  • All tests passing
  • Samples run successfully
  • Extended the README / documentation, if necessary

@LossyDragon LossyDragon merged commit c44c708 into Longi94:master Feb 5, 2025
1 check passed
@LossyDragon LossyDragon deleted the websocket-ktor branch February 5, 2025 01:29
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

Successfully merging this pull request may close these issues.

1 participant