X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=game.js;h=eb1ba807c3e1d9ec5a0e9eda65fceafaff052338;hb=9fb6009a9666b92b18436975409d3717128ec9ba;hp=bf74de46105aa62804c17b196c5df2fe4e9d3fd8;hpb=e368873853353b4b8949bfdf3c560b484e4cfb88;p=lmno-server diff --git a/game.js b/game.js index bf74de4..eb1ba80 100644 --- a/game.js +++ b/game.js @@ -224,6 +224,10 @@ class Game { this.broadcast_string(`event: ${type}\ndata: ${data}\n`); } + broadcast_event_object(type, obj) { + this.broadcast_event(type, JSON.stringify(obj)); + } + handle_events(request, response) { /* These headers will keep the connection open so we can stream events. */ const headers = { @@ -306,7 +310,7 @@ class Game { } broadcast_move(move) { - this.broadcast_event("move", move); + this.broadcast_event("move", JSON.stringify(move)); } }