diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/hello.ml | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/hello.ml b/test/hello.ml index 1659787..9b58de1 100644 --- a/test/hello.ml +++ b/test/hello.ml @@ -2,15 +2,15 @@ open! Lwt.Syntax open! Lwt.Infix open! Flesh -let program (stream, push) config (features : Stream.features) = - let+ _auth = Sasl.authenticate (stream, push) config features.mechanisms +let program (p : Portal.t) config (features : Stream.features) = + let+ _auth = Sasl.authenticate p config features.mechanisms in begin match _auth with | Error (NotAuthorized, Some (_, text)) -> print_endline ("Not authorized: " ^ text) | Error (MalformedRequest, Some (_, text)) -> print_endline ("Malformed request: " ^ text) | Error _ -> print_endline "Error!" | Ok _ -> print_endline "Success!" end; - Portal.close (stream, push) + Portal.close p let main = let config : Sasl.auth_config = { @@ -19,12 +19,12 @@ let main = preferred_mechanisms = [Sasl.PLAIN] } in let domain = (List.nth (String.split_on_char '@' config.jid) 1) in - let* stream, push = Portal.connect domain in - let* features = Stream.negotiate domain (stream, push) in + let* portal = Portal.connect domain in + let* features = Stream.negotiate domain portal in Lwt.catch - (fun () -> program (stream, push) config features >|= (fun () -> push None)) + (fun () -> program portal config features >|= (fun () -> portal.push None)) (fun exn -> - push None; + portal.push None; (* I suspect JavaScript's [wrap_callback] swallows the Exceptions thrown by OCaml, so... The next best thing is probably printing something. *) print_endline |