Networking of a Turn-Based Game
longwelwind.net3 pointsby Longwelwind0 comments
async function handleUpdate(update) {
if (update.type == "sell-items") {
this.player.inventory[update.itemId] -= 1;
await emitEvent("itemSold");
this.player.money += 10;
await emitEvent("moneyGain");
}
}
Server-side, "emitEvents" would be a no-op. Everything would resolve synchronously.