How to avoid SDL flooding ?

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

How to avoid SDL flooding ?

Postby tachzusamm » Sun Aug 04, 2013 3:31 pm

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?
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: How to avoid SDL flooding ?

Postby diafero » Mon Aug 05, 2013 1:58 am

(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.
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: How to avoid SDL flooding ?

Postby tachzusamm » Mon Aug 05, 2013 3:36 am

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.)
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany


Return to Scripting

Who is online

Users browsing this forum: No registered users and 4 guests

cron