From 519cca49042948b01b63ba2a6eb5392de11d69bd Mon Sep 17 00:00:00 2001 From: Clombrong Date: Mon, 30 Jun 2025 20:09:13 +0200 Subject: feat(sasl): use Jid.t as the jid type --- test/hello.ml | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'test') diff --git a/test/hello.ml b/test/hello.ml index a43b90a..55a735e 100644 --- a/test/hello.ml +++ b/test/hello.ml @@ -6,30 +6,22 @@ let main = let config : Stream.config = { starttls = {prefer = true}; sasl = { - jid = (Sys.getenv "FLESH_JID"); + jid = Jid.of_string (Sys.getenv "FLESH_JID"); password = (Sys.getenv "FLESH_PASSWORD"); preferred_mechanisms = [Sasl.PLAIN] }; other = []; } in - begin - let jid = Jid.of_string (Sys.getenv "FLESH_JID") - in - Option.iter print_endline jid.localpart; - print_endline jid.domainpart; - Option.iter print_endline jid.resourcepart; - end; - let domain = (List.nth (String.split_on_char '@' config.sasl.jid) 1) in - try%lwt connect domain config >|= (fun (portal, _) -> portal.push None) - with exn -> - begin - (* I suspect JavaScript's [wrap_callback] swallows the Exceptions thrown by - OCaml, so... The next best thing is probably printing something. *) - print_endline - (match exn with - | Xml.InvalidStanza stanza -> "Invalid stanza: " ^ stanza - | Portal.MalformedStanza err -> "Server sent malformed stanza: " ^ (Markup.Error.to_string err) - | _ -> "... and so I stumble back to bed."); - Lwt.fail exn - end + try%lwt connect config.sasl.jid.domainpart config >|= (fun (portal, _) -> portal.push None) + with exn -> + begin + (* I suspect JavaScript's [wrap_callback] swallows the Exceptions thrown by + OCaml, so... The next best thing is probably printing something. *) + print_endline + (match exn with + | Xml.InvalidStanza stanza -> "Invalid stanza: " ^ stanza + | Portal.MalformedStanza err -> "Server sent malformed stanza: " ^ (Markup.Error.to_string err) + | _ -> "... and so I stumble back to bed."); + Lwt.fail exn + end -- cgit v1.2.3