From 41aa93cf6465201447e13e9db0440aaac00cb4e2 Mon Sep 17 00:00:00 2001 From: Clombrong Date: Thu, 26 Jun 2025 22:15:12 +0200 Subject: feat(portal): change type t into a record --- test/hello.ml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test') 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 -- cgit v1.2.3