I'm trying to make a video game using WebChannel. My problem is that I'm getting a stale state when new clients join. Because WebChannel only gives updates whenever properties get emitted, the clients are presented with incorrect world state always and forever.
So looking at QMetaObjectPublisher, in the `initializeClient` method, for every new client that joins the code iterates through all the registered objects and calls the method `classInfoForObject`. Which is perfect and prevents the stale state issue right?
Well if you take a look at the `classInfoForObject` method, you can skip everything except for the thing we're interested in, where does the state get read? And that's in the line of code where we go:
The `read` method is the important bit, because we're actually reading what the property is. But what's the `wrapResult` method doing?
If you look at the `wrapResult` method, you can skip down to the bit of code where we assume we've already wrapped the object once (`else if (wrappedObjects.contains(id))`), you'll find where I assume I'm getting the stale cache from
`classInfo = wrappedObjects.value(id).classinfo;`
If you change that line of code to `classInfo = classInfoForObject(object, transport);`, then everything works as expected. There's probably a more elegant way to do this.
Recursion, networking, and state. Dangerous combo.