Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#4482 closed defect (fixed)

Improve XmppClient GUIMessage struct handiness

Reported by: elexis Owned by:
Priority: Should Have Milestone: Alpha 23
Component: Multiplayer lobby Keywords:
Cc: Patch: Phab:D835

Description (last modified by elexis)

The lobby xmpp code sends messages to JS via custom struct. But that is bad since it hardcodes a set of possible arguments. Some examples:

  • If someone changes the nickname, the old nick will be sent in text and the new name will be sent in data, entirely undescriptive
  • If someone is kicked (https://code.wildfiregames.com/D116), the nickname will be sent in text and the disconnect reason in the data` field

The custom struct is then parsed to a JS::MutableHandleValue in GuiPollMessage.

Instead we should create those JS values directly, thus allowing to easily add further arguments. It would also allow merging the "kick" and "ban" case and just pass another boolean.

The code will then appear comparable to CNetClient::GuiPoll and PushGuiMessage.

Change History (8)

comment:1 by elexis, 7 years ago

Description: modified (diff)

It would becmoe a std::deque<JS::Heap<JS::Value>> m_GuiMessageQueue just like in the NetClient.h.

comment:2 by elexis, 7 years ago

Keywords: simple removed
Milestone: BacklogAlpha 23
Patch: Phab:D835
Priority: Nice to HaveShould Have

comment:3 by elexis, 7 years ago

In 20064:

XmppClient cleanup.

Allow XmppClient to use arbitrary property names in GUIMessages.
Remove duplication by calling CreateGUIMessage when receiving chat messages.
Inline PushGUINotification.
Use std::string in the GUIMessage because every data source is of that type.
Apply the wstring_from_utf8 conversion to ensure correct display of less common UTF characters instead in the GuiPollMessage method.
Add room subject change chat message.

Differential Revision: https://code.wildfiregames.com/D835
Refs #4482
Comments by fpre, Vladislav and leper

comment:4 by elexis, 7 years ago

Resolution: fixed
Status: newclosed
Summary: Nuke XmppClient GUIMessage structImprove XmppClient GUIMessage struct handiness

Works for now. Creating a custom ScriptInterface by itself can cause trouble and isn't necessary or an enhancement.

comment:5 by elexis, 6 years ago

Since we need a third property in at least one case, the ScriptInterface approach might be nicer, see #4877.

comment:6 by elexis, 5 years ago

In r22856:

Support creating lobby GUI messages with arbitrary arguments instead of forcing every message type into the same struct type, refs #4877 / rP19514 / D339.

Creates the GUI messages directly as JS::Values and removes the intermediary rigid struct. Implementation similar to ScriptInterface::CreateObject? from D2080.

Differential Revision: ​https://code.wildfiregames.com/D2264
Tested on: clang 8.0.1, Jenkins

comment:7 by elexis, 5 years ago

In 22859:

Fix wrong "player is not a moderator anymore" lobby chat message following initial implementation in rP19514/D339, fixes #4877.

It needs to test against the historic role and not the current role, similar to rP16997, refs #3386.
Implements the third GUI message property using the arbitrary lobby GUI message patch in rP22856/D2264, refs #4482, rP22855/D2265.

Differential Revision: https://code.wildfiregames.com/D2266
Tested on: clang 8.0.1

comment:8 by elexis, 5 years ago

In 22880:

Pass XmppClient CertificateErrorToString independent of ConnectionErrorToString to JS using D2264 / rP22856, refs #4482.

This also allows making the enum to string functions static, refs D2271.

Differential Revision: https://code.wildfiregames.com/D2274
Tested on: clang 8.0.1, Jenkins

Note: See TracTickets for help on using tickets.