Closed Luluno01 closed 4 years ago
I'm going to close this, because this is a consequence of how GC connections work. Basically, saying that you have a "connection" to the GC is kind of wrong. It's more of a UDP type of thing rather than a TCP type of thing. Messages get sent to the GC via Steam and Steam essentially just passes them along as-is. There is no concept of a "connection", only GC sessions.
It seems that sometimes when you go out-of-game, Steam doesn't relay that along to the GC so the session is not terminated. In that case, the GC just waits for the session to time out, I suppose. Sending a request while out-of-game doesn't work because Steam won't relay a message to a GC unless you're in that game.
You then go in-game and the GC never saw you as having left. connectedToGC
will eventually get emitted because a new session will be negotiated, but your old session is actually still valid.
Regardless, even if there is technically an active session, I would rather keep the documentation saying that you need to wait for connectedToGC
, to prevent confusion.
@DoctorMcKay Thanks for your explanation! My workaround is to fully relogin and reconnect when user becomes offline or when GC disconnects to ensure a valid GC session.
Problem description
The documentation requires users try to do nothing before receiving the
connectedToGC
event. At the same time it requires users to call methods only when thehaveGCSession
istrue
.However, I noticed that I can actually send item inspect queries and receive responses from the server when
haveGCSession
isfalse
.Now I have to explain why my
haveGCSession
property isfalse
and that's actually another issue:I called
user.gamesPlayed(730)
for the first time, and receivedconnectedToGC
event as expected. I checked thehaveGCSession
property, it was alsotrue
as expected. Later, I calleduser.gamesPlayed([])
, thedisconnectedFromGC
event did not fired buthaveGCSession
becamefalse
. I also calledinspectItem
after that, no response received (that is what I expected). Finally, I calleduser.gamesPlayed(730)
again and:connectedToGC
event firedhaveGCSession
was stillfalse
I was confused, so I called
inspectItem
to see what would happen, and I received responses to the inspect query.Also, there could be a connection leak caused by the aforementioned operation sequence as mentioned here.