summaryrefslogtreecommitdiff
blob: 3ebdd8b4e6f2e436b908bf828c8118a88a7856c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-module(battlemap_load_state).

-export(
   [
      handle/1
   ]
).

handle (Req) ->
   JSONReqMap = jiffy:decode(Req, [return_maps]),
   BattlemapID = maps:get(<<"battlemap_id">>, JSONReqMap),
   io:format("~nLoading Battlemap ~p...", [BattlemapID]),
   Battlemap = timed_cache_object:fetch(battlemaps_db, BattlemapID, 60000),
%%   ok = users_manager:ping(UserToken),
   jiffy:encode(
      {
         [
            {<<"types">>, [<<"STATE">>]},
            {
               <<"data">>,
               [
                  battlemap_battlemap:encode_to_json(Battlemap)
               ]
            }
         ]
      }
   ).