From c91d16adf3253ff1224fb093c7708964e6b2a978 Mon Sep 17 00:00:00 2001 From: Clombrong Date: Tue, 17 Jun 2025 23:38:08 +0200 Subject: feat(portal-websockets): return a stream of signals with stanza_open --- portal/lib/dune | 2 +- portal/lib/portal.mli | 4 +++- portal/lib/ws/dune | 2 +- portal/lib/ws/portal.ml | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/portal/lib/dune b/portal/lib/dune index 1a330b9..736a2d4 100644 --- a/portal/lib/dune +++ b/portal/lib/dune @@ -1,4 +1,4 @@ (library (public_name portal) (virtual_modules portal) - (libraries lwt)) + (libraries lwt markup markup-lwt)) diff --git a/portal/lib/portal.mli b/portal/lib/portal.mli index c9b2460..7f9dc0d 100644 --- a/portal/lib/portal.mli +++ b/portal/lib/portal.mli @@ -1,6 +1,8 @@ +open Markup + type t = string Lwt_stream.t * (string option -> unit) -val stanza_open : ?from:string -> string -> string +val stanza_open : ?from:string -> string -> (signal, sync) stream val stanza_close : string diff --git a/portal/lib/ws/dune b/portal/lib/ws/dune index fa14219..22de458 100644 --- a/portal/lib/ws/dune +++ b/portal/lib/ws/dune @@ -2,5 +2,5 @@ (name portal_ws) (implements portal) (public_name portal-websockets) - (libraries lwt js_of_ocaml js_of_ocaml-lwt xmlm markup markup-lwt) + (libraries lwt js_of_ocaml js_of_ocaml-lwt markup markup-lwt) (preprocess (pps js_of_ocaml-ppx))) diff --git a/portal/lib/ws/portal.ml b/portal/lib/ws/portal.ml index e0c76b4..7b79166 100644 --- a/portal/lib/ws/portal.ml +++ b/portal/lib/ws/portal.ml @@ -1,6 +1,7 @@ open Lwt.Syntax open Lwt.Infix open Js_of_ocaml +open Markup let jss = Js.string let sjs = Js.to_string @@ -9,7 +10,7 @@ type t = string Lwt_stream.t * (string option -> unit) (* sic. XEP-0156: "host-meta files MUST be fetched only over HTTPS". I don't make the rules. *) let well_known_of (domain : string) = "https://" ^ domain ^ "/.well-known/host-meta" -let stanza_open ?from domain = +let stanza_open ?from domain : (signal, sync) stream = (** [open_stanza domain] is an stanza for [domain]. If [from] is specified, the stanza has the from parameter. @@ -27,7 +28,7 @@ let stanza_open ?from domain = (("urn:ietf:params:xml:ns:xmpp-framing", "open"), attributes); `End_element] - in stanza |> of_list |> write_xml |> to_string + in stanza |> of_list let stanza_close = {||} -- cgit v1.2.3