Page 1 of 1

How to avoid SDL flooding ?

PostPosted: Sun Aug 04, 2013 3:31 pm
by tachzusamm
I made a python script which reacts on SDL changes in OnSDLNotify.
Now, based on the state of an SDL variable, or more of them, I make further changes (writes) to other SDL variables.

But in this case, each player gets notified in OnSDLNotify, and therefore each player would cause further SDL changes - which could end in SDL flooding or unnecessary network activity, I assume.
It would be sufficient if only the player who initially caused the first SDL change does further changes of dependent variables.

How can I achieve this?


Does the playerID in OnSDLNotify ("def OnSDLNotify(self, VARname, SDLname, playerID, tag):") identify the player who caused the SDL change?

Re: How to avoid SDL flooding ?

PostPosted: Mon Aug 05, 2013 1:58 am
by diafero
(argh I HATE phpBB for forgetting my post when I got somehow logged out while typing - now the answer will be much shorter than previously was I don't want to re-type it all)

Make sure your Python script somehow has access to a scene object on the main page of the age (or any page that's guaranteed to be loaded for everyone in the age). Then call isLocallyOwned on that scene object, and only handle the SDL events if it returns True. Client and server cooperatively ensure that there's always exactly one client owning a page, so by checking who owns the page this scene object is on (which is what isLocallyOwned does), you can be sure that there's one "master" player doing all the SDL event handling. When that player unloads the page, the server will make a new player the master and tell it that (s)he now owns the page.

Re: How to avoid SDL flooding ?

PostPosted: Mon Aug 05, 2013 3:36 am
by tachzusamm
A-ha. That explains it nicely, thank you diafero.
(I was already wondering what isLocallyOwned does; its method name is not very self-explanatory. Sounds more like "pwned!!" :D )

And:
diafero wrote:(argh I HATE phpBB for forgetting my post when I got somehow logged out while typing - now the answer will be much shorter than previously was I don't want to re-type it all)

*signed*
I sometimes use strg-A + strg-C when writing long posts, just in case - like I'm used to do a strg-S from time to time in a text editor. (strg = ctrl on US keyboards.)