aboutsummaryrefslogtreecommitdiff
path: root/lib/stream.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stream.ml')
-rw-r--r--lib/stream.ml8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/stream.ml b/lib/stream.ml
index 25b6822..677b60d 100644
--- a/lib/stream.ml
+++ b/lib/stream.ml
@@ -3,6 +3,12 @@ open Lwt.Syntax
exception ClosedStream
exception InvalidStanza of string
+let get stream =
+ let* stanza = Lwt_stream.get stream
+ in match stanza with
+ | Some stanza -> Lwt.return stanza
+ | None -> Lwt.fail ClosedStream
+
let start domain : Portal.t Lwt.t =
(** [start domain] is a promise containing a Portal (stream * push) connected to the XMPP server [domain].
@@ -14,5 +20,5 @@ let start domain : Portal.t Lwt.t =
| anything -> _push anything
in Some (Portal.stanza_open domain) |> push;
(* TODO: check this is a good stanza *)
- let+ _ = Lwt_stream.get stream
+ let+ _ = get stream
in stream, push