Character-level protocol
Race condition on Wave Gadget
That said, it seems that Wave Gadget may run into race condition.
If one participant write "gamestate"=1 into wave gadget state and the other party write "gamestate"=5. Then whoever writes later will overwrite the other's change.
To make it more concrete:
Let's say that both party check state to see if a host for the game is selected. If not, claim to be host and save it to state.
- party1 calls wave.getState() to and sees that "gamehost" property is absent. So gamehost is not selected.
- party2 calls wave.getState() to and sees that "gamehost" property is absent. So gamehost is not selected.
- party1 go ahead and claim to be gamehost and write the state "gamehost=party1" (by calling wave.getState().submitDelta())
- party2 go ahead and claim to be gamehost and write the state "gamehost=party2"
- Now both side think they are the host. Whoever writes last will overwrite the other side's state.
Hopefully there will be better control about race condition in Wave Gadget later.
No comments:
Post a Comment