Page MenuHomeWildfire Games

Keep lobby history
ClosedPublic

Authored by ffffffff on Aug 21 2017, 2:30 AM.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

ffffffff created this revision.Aug 21 2017, 2:30 AM
elexis requested changes to this revision.Aug 21 2017, 2:55 AM
elexis added inline comments.
binaries/data/mods/public/gui/lobby/lobby.js
366 ↗(On Diff #3247)

some JS comment stating what that call is good for

369 ↗(On Diff #3247)

for (let msg of Engine....)

source/lobby/XmppClient.cpp
590 ↗(On Diff #3247)

const &

603 ↗(On Diff #3247)

Remove duplication by using a new helper function

624 ↗(On Diff #3247)

JS_NewArrayObject, JS_SetElement
See VisualReplay::GetReplays for example

source/lobby/XmppClient.h
172 ↗(On Diff #3247)

comment explaining what that is used for

This revision now requires changes to proceed.Aug 21 2017, 2:55 AM
ffffffff added inline comments.Aug 21 2017, 4:10 AM
source/lobby/XmppClient.cpp
582 ↗(On Diff #3247)

lines before i actualy want to use the function SetJSMessageProperties() also but i cannot get it to work cause the JS::RootedValue ret variable is another than the JS::MutableHandleValue from the GuiPollMessage function. if someone get this figured out would be nice. it works in either way now its just to get some doubled code reduced.

Please upload your patches with 9999 lines of context from now on. It says "context not available" everywhere, while we could read the surrounding code if you did.

svn diff --diff-cmd diff -x "-p -U9999" .
ffffffff added inline comments.Aug 21 2017, 1:49 PM
source/lobby/XmppClient.cpp
624 ↗(On Diff #3247)

is this bad cause i take this from GUIGetPlayerList

ffffffff updated this revision to Diff 3252.EditedAug 21 2017, 1:53 PM
ffffffff edited edge metadata.

context, const changes, commentary, helper

ffffffff marked an inline comment as done.Aug 21 2017, 1:54 PM
ffffffff updated this revision to Diff 3256.Aug 21 2017, 4:13 PM

JS_SetElement JS_NewArrayObject

Thanks for the context. Has helped already.
Patch looks ok mostly. Didn't test it yet.

source/lobby/IXmppClient.h
59 ↗(On Diff #3256)

Weird that GuiPollMessage and GuiPollAllMessages have a different number of arguments and different return types.

source/lobby/XmppClient.cpp
568 ↗(On Diff #3256)

Why isn't scriptInterface.Eval("({})", ret); done in the helper?

581 ↗(On Diff #3256)

Probably ok to not call JSAutoRequest, as we're not registering new variables.
Maybe better to do it anyway for good measure.
Perhaps even best to search the other code and look at docs and old tickets to find out when we need it exactly.

Actually this function should be deleted altogether in a separate patch: #4482.

598 ↗(On Diff #3256)

commented code

606 ↗(On Diff #3256)

reference instead of copy, i.e. missing &

613 ↗(On Diff #3256)

++i

ffffffff added inline comments.Aug 21 2017, 5:59 PM
source/lobby/XmppClient.cpp
613 ↗(On Diff #3256)

L235 visualreplay.cpp JS_SetElement(cx, replaysWithoutNullEntries, i++, replay); xD

Can't wait to see this committed, after the renames, two comment changes and someone having checked the reference.

binaries/data/mods/public/gui/lobby/lobby.js
366 ↗(On Diff #3247)

// Display chat messages when returning from a game ?

369 ↗(On Diff #3263)

Correct in all cases called (when registering an account, logging in, logging in + receiving historic messages, returning from a game,), because LobbyGuiPollAllMessages covers all these cases.

source/lobby/XmppClient.cpp
561 ↗(On Diff #3263)

Mh, don't we miss a reference here (as in doing an unneeded copy)? Is that the reason why the pop was done after reading from it?

564 ↗(On Diff #3263)

comment unneeded IMO as the code below is self-evident

565 ↗(On Diff #3263)

In the future we might want to extend this, so that people can also follow bans/kicks and error messages.

Perhaps we can just remember all messages, but there was a huge performance problem at the time when processing too many state changes after returning from a long game, which was the introduction of ClearPresenceUpdates.

I wonder how we filter those. Perhaps we should push a <std::pair<std::string, JS::Heap<JS::Value>>, so that the first` element of the pair shows us the type to filter.

566 ↗(On Diff #3263)

I'll never understand whether to use push_back or emplace_back, since everyone says something different on the topic.
push_back is at least used twice, so we can keep it consistent at least.

573 ↗(On Diff #3263)

(Actually this function looks like it should go into GUIScriptConversions.cpp, but deleting it will be better.)

591 ↗(On Diff #3263)

No need to rename ret

601 ↗(On Diff #3263)

ret -> messages?

603 ↗(On Diff #3263)

uint32_t is what JS_SetElement takes: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetElement

Then we can start at 0 and are exempt from the CodingConventions and must use i++. (didn't consider it the first time)

610 ↗(On Diff #3263)

(The entire array to JS::Value conversion can be avoided if we would have added it to GUIConversions.cpp, but.... deletion is better)

source/lobby/XmppClient.cpp
561 ↗(On Diff #3263)

thats it u want this copy or again some overhead having later SetJSMessageProperties returned

565 ↗(On Diff #3263)

i hope u can help me ther i will now nuke this if

566 ↗(On Diff #3263)

ok i take push_back

ffffffff updated this revision to Diff 3271.Aug 21 2017, 10:09 PM
ffffffff added inline comments.Aug 21 2017, 10:30 PM
source/lobby/XmppClient.cpp
561 ↗(On Diff #3263)

actualy it says front() returns reference to front

ffffffff added inline comments.Aug 21 2017, 11:19 PM
source/lobby/XmppClient.cpp
601 ↗(On Diff #3263)

yes

ffffffff added inline comments.Aug 22 2017, 1:44 PM
source/lobby/XmppClient.cpp
565 ↗(On Diff #3263)

kick ban are chat messages type

ffffffff added inline comments.Aug 22 2017, 1:48 PM
source/lobby/XmppClient.cpp
565 ↗(On Diff #3263)

its just game and system network message that are being not saved. these are errors disconnect/connect and update messages for the panel.

ffffffff updated this revision to Diff 3284.Aug 22 2017, 1:51 PM

set history flag for saved messages, that has been poped out of messages queue and shown to user, so they can be seen as history messages.

ffffffff updated this revision to Diff 3286.Aug 22 2017, 2:42 PM

msg.saved flag instead of msg.history flag to say its saved (and though has been shown before in queue)

elexis requested changes to this revision.Aug 28 2017, 5:17 PM

Every message received from LobbyGuiPollAllMessages is a historic message. So there is no need to add that saved flag in C++.
So that SetJSMessageProperties doesn't have to be added.

Can just set msg.historic = true in the for (let msg of Engine.LobbyGuiPollAllMessages()) loop.

Since there are a bunch of merge conflicts already, I'll commit D835 so that we don't have to spend even more time on this.

if (message.type == L"chat") -> Ah, that does actually include kick,, ban, role, nick as wanted. But including join and leave sounds wrong, because they cost too much performance in case hundreds of them accumulate while playing a game (which is the reason why we have added ClearPresenceUpdates)

source/lobby/XmppClient.cpp
611 ↗(On Diff #3286)

Is JS::ObjectValue needed?

This revision now requires changes to proceed.Aug 28 2017, 5:17 PM
elexis accepted this revision.Aug 29 2017, 6:01 PM

(Actually if were already creating a copy when converting the struct to a JSval, might want to set the property there instead of JS, so nevermind what I recommended)

GuiMessageToJSVal is a better name for that new helper function.

Trying to avoid the copy by popping after the conversion to JS val just gets us funny segfaults:

+	const GUIMessage message = m_GuiMessageQueue.front();
+	m_GuiMessageQueue.pop_front();

Another way to get funny results is by using a std::move in the std::push statement of historic messages, so not doing that.

Patch is good and correct as is (and complete), given rebase, renames and the presence-change ignoring for historic messages.

Thanks!

source/lobby/IXmppClient.h
59 ↗(On Diff #3286)

const ScriptInterface ref

source/lobby/XmppClient.cpp
565 ↗(On Diff #3263)

if (message.type == L"chat") should do the same as ClearPresenceUpdates

source/lobby/XmppClient.h
150 ↗(On Diff #3286)

going for GuiPollNewMessage and GuiPollHistoricMessages

This revision is now accepted and ready to land.Aug 29 2017, 6:01 PM
This revision was automatically updated to reflect the committed changes.