diff options
| author | Adelyn Breedlove <[email protected]> | 2019-01-16 23:36:59 -0700 |
|---|---|---|
| committer | Adelyn Breedlove <[email protected]> | 2019-01-16 23:36:59 -0700 |
| commit | 6354dbd89d354e5e2499b4c2bea5d5fa95e020df (patch) | |
| tree | a0fd199097bdc675628d5bd735017d92d2067e08 /lib/event.ml | |
| parent | Merge branch 'switch-to-deriving_yojson' into 'master' (diff) | |
| download | disml-6354dbd89d354e5e2499b4c2bea5d5fa95e020df.tar.xz disml-6354dbd89d354e5e2499b4c2bea5d5fa95e020df.zip | |
eliminate all functors in favour of a simpler approach
Diffstat (limited to 'lib/event.ml')
| -rw-r--r-- | lib/event.ml | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/event.ml b/lib/event.ml index d6a6372..6684053 100644 --- a/lib/event.ml +++ b/lib/event.ml @@ -75,4 +75,12 @@ let event_of_yojson ~contents t = match t with | "VOICE_STATE_UPDATE" -> VOICE_STATE_UPDATE contents | "VOICE_SERVER_UPDATE" -> VOICE_SERVER_UPDATE contents | "WEBHOOKS_UPDATE" -> WEBHOOKS_UPDATE contents - | s -> raise @@ Invalid_event s
\ No newline at end of file + | s -> raise @@ Invalid_event s + +let dispatch ~ev contents = + (* Printf.printf "Dispatching %s\n%!" ev; *) + (* print_endline (Yojson.Safe.prettify contents); *) + try + event_of_yojson ~contents ev + |> ignore; (* TODO make this point to the new hanler *) + with Invalid_event ev -> Printf.printf "Unknown event: %s%!" ev
\ No newline at end of file |