diff options
Diffstat (limited to 'lib/dispatch.ml')
| -rw-r--r-- | lib/dispatch.ml | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/dispatch.ml b/lib/dispatch.ml index 66c6fee..4a9b791 100644 --- a/lib/dispatch.ml +++ b/lib/dispatch.ml @@ -1,7 +1,9 @@ -module Make(H : S.Handler) : S.Dispatch = struct +module Make(H : sig val handle_event : Event.t -> unit end) : S.Dispatch = struct let dispatch ~ev contents = - Printf.printf "Dispatching %s\n%!" ev; + (* Printf.printf "Dispatching %s\n%!" ev; *) (* print_endline (Yojson.Safe.prettify contents); *) - Event.event_of_string ~contents ev - |> H.handle_event + try + Event.event_of_yojson ~contents ev + |> H.handle_event + with Event.Invalid_event ev -> Printf.printf "Unknown event: %s%!" ev end
\ No newline at end of file |