diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-26 22:15:12 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-27 08:56:42 +0200 |
commit | 41aa93cf6465201447e13e9db0440aaac00cb4e2 (patch) | |
tree | 6a5e6e810870b8c180f6cb2015a448de72a30134 /test | |
parent | 3f9271f38f49d38a583ec99ec1ddf81a45945e73 (diff) |
feat(portal): change type t into a record
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 |