diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-03-05 11:32:38 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-03-05 16:47:03 +0100 |
commit | 875e12b88f55250c4adb0a5304b150ac00ce4efd (patch) | |
tree | 02bda4f21936047a8daae8ace5170eade9f9f1ce /public | |
parent | 4e85d56e9cd74f3e2b2c596ce3ca31312f281661 (diff) | |
download | server-875e12b88f55250c4adb0a5304b150ac00ce4efd.tar.gz |
Add query/reply API to server and modules.
Diffstat (limited to 'public')
-rw-r--r-- | public/common/play.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/public/common/play.js b/public/common/play.js index e58ca04..0fa432a 100644 --- a/public/common/play.js +++ b/public/common/play.js @@ -376,12 +376,18 @@ function connect_play() { case 'state': view = arg; on_update_header(); - on_update(); + if (typeof on_update === 'function') + on_update(); on_update_log(); if (view.game_over) on_game_over(); break; + case 'reply': + if (typeof on_reply === 'function') + on_reply(arg[0], arg[1]); + break; + case 'save': window.localStorage[params.title_id + "/save"] = arg; break; @@ -547,6 +553,13 @@ function send_action(verb, noun) { return false; } +function send_query(q, param) { + if (param !== undefined) + send_message("query", [q, param]); + else + send_message("query", q); +} + function confirm_resign() { if (window.confirm("Are you sure that you want to resign?")) send_message("resign"); |