octgn / OCTGN

Online Card and Tabletop Gaming Network
http://www.octgn.net
Other
360 stars 129 forks source link

Add synrchonous remoteCalls #1370

Open db0 opened 9 years ago

db0 commented 9 years ago

a synchronous remoteCall is a remote call that blocks execution until it returns.

I'm trying to use complex code but due to the peculiarities of OCTGN, async remoteCalls forcing me to do more and more hacks to work around issues I encounter.

Simple example: If I want to move a card of another player to the table and then add some markers, I do remoteCall(card.controller,'moveCardWrapper',[card,x,y]) but if I try to add a marker afterwards, the card might not be on the table yet, which will cause issues.

If I work around this by ending the whole function at the point where I want to move the card and then have the other player remotecall it back to it (or a different function) to continue, then any other script that might call this function has to ALSO remoteCall it (even though it might not affect cards I don't control always) or otherwise as soon as the remoteCall end is reached within the called function, the parent function will continue, even though the scripts it's expecting have not been finished yet.

Here's a scenario I just finished hacking around

So to make this work, I need to remoteCall myself with the function which will move the card around. This is the only way to ensure that the scripts execute in the right order.

As the complexity of the code increases, the only way to ensure that scripts will fire in the right order which includes checking status of card highlight, markers etc, is to remoteCall every function call to myself. Which I do not think is how it's supposed to be.

A synchronous remoteCall would allow me to call remoteCalls without having to think how this affects the whole execution path due to queues or network delays.

Gravecorp commented 9 years ago

This can be easily achieved even with async calls. All you have to do is either chain your async calls back and forth or properly use callbacks.

db0 commented 9 years ago

Easily, no. It's in fact a huge rework due to having to do remote calls inside for-loops, and it messes up the flow of the code something awful.

I can make everything work (and I have), even gotos, but it doesn't make it a good idea. I want something that I can use as a normal function. With a proper return is possible.

brine commented 9 years ago

I am cleaning up this thread. The general consensus is that this feature (among many others) is not elegantly handled in the current OCTGN design, mainly due to the local player-centric python executions. It would greatly benefit from the ability to execute python code on the server, which is currently one of the major goals planned for OCTGN.

Note that this thread is NOT closed -- I would prefer if we came up with a "temporary" solution in the meantime to handle this sort of mechanism, as there is some great applications for it.