Opened 5 years ago
Last modified 5 years ago
#5585 new defect
Networked GUI message callback handler
Reported by: | elexis | Owned by: | |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Backlog |
Component: | Network | Keywords: | |
Cc: | Patch: |
Description (last modified by )
For the XmppClient and NetClient, there are messages created upon receiving a networked message to be pulled by the GUI.
The GUI pages then load these messages each tick
.
But it seems cleaner to post a JS function to the GUI page that is called everytime one or multiple network-GUI messages are to be processed.
Notice that the XmppClient relies on processing messages in batches, and only updates the playerlist once after all messages that affect the playerlist have been processed, i.e. at most once per frame. It shouldn't be changed in such a way that the playerlist is updated hundreds of times when there are hundreds of messages after returning from a game (been there -> #3386).
The GUI page could in fact register JS handler functions for each message type, rather than pulling a message this way.
Then the JS GUI page could also decide to not subscribe to some messages (for example presence changes are currently unused in the GUI, but one can also add more XMPP MUC event support that may be unused in our GUI)
---
If one takes a look at the current (22885) lobby.js
, g_NetMessageTypes
could hardly become simpler or more extensible.
We certainly don't want 20 different JSInterface functions (one per message type), one function should suffice to subscribe every messagetype processor.
---
In fact the updatePlayerList
function could also be called from C++ directly and at most once per frame, thus avoiding onTick()
in lobby.js
completely except for the unrelated updateTimers();
call.