From 79d15a2baec54f10ba5114667d3d686982a90bee Mon Sep 17 00:00:00 2001 From: Clombrong Date: Fri, 27 Jun 2025 08:22:57 +0200 Subject: feat(portal): make close a simple stanza --- portal/portal.mli | 6 ++++-- portal/tcp/portal.ml | 4 ++-- portal/ws/portal.ml | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'portal') diff --git a/portal/portal.mli b/portal/portal.mli index 808e1fa..5efc355 100644 --- a/portal/portal.mli +++ b/portal/portal.mli @@ -23,7 +23,9 @@ val xmlns : string When [from] is specified, a from attribute is included. *) val header : ?from:string -> string -> t -> string Lwt.t -(** [close portal] closes the stream between [portal] and the XMPP server. *) -val close : t -> unit +(** [close] is a stream of signals that close the Portal, indicating to the XMPP server + that the connection is closed. Namely, it does {b not} interact with the Portal in + any way: It's the caller's job to provide it to the stream. *) +val close : (signal, sync) stream val connect : string -> t Lwt.t diff --git a/portal/tcp/portal.ml b/portal/tcp/portal.ml index 8d0c8fc..61e1b40 100644 --- a/portal/tcp/portal.ml +++ b/portal/tcp/portal.ml @@ -51,8 +51,8 @@ let header ?from domain ({stream; push; _} : t) = | Some id -> Lwt.return id | None -> Lwt.fail_with "Invalid stream opening server-side." - -let close {push; _} = [`End_element] |> Markup.of_list |> Option.some |> push +(** [close portal] is a closing tag to the [] document. *) +let close = [`End_element] |> Markup.of_list (** [xmpp_port domain] is the port where [domain]'s XMPP server is hosted. diff --git a/portal/ws/portal.ml b/portal/ws/portal.ml index dfd12cf..233ea8d 100644 --- a/portal/ws/portal.ml +++ b/portal/ws/portal.ml @@ -50,8 +50,8 @@ let header ?from domain {stream; push; _} = | Some id -> Lwt.return id | None -> Lwt.fail_with "Invalid stream opening server-side." -let close {push=p; _} = - {||} |> string |> parse_xml |> signals |> Option.some |> p +(** [close] is a [] stanza. *) +let close = {||} |> string |> parse_xml |> signals exception MalformedStanza of Markup.location * Markup.Error.t -- cgit v1.2.3