aboutsummaryrefslogtreecommitdiff
path: root/test/hello.ml
blob: ef24804cbd2bdbee38e4bc0f2e70d0cc7640827f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
open! Lwt.Syntax
open! Lwt.Infix
open! Flesh

let main =
  let config : Sasl.auth_config = {
      jid = (Sys.getenv "FLESH_JID");
      password = (Sys.getenv "FLESH_PASSWORD");
      preferred_mechanisms = [Sasl.PLAIN]
    }
  in let domain = (List.nth (String.split_on_char '@' config.jid) 1) in
     try%lwt Stream.initiate 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
            | _ -> "... and so I stumble back to bed.");
         Lwt.fail exn
       end