aboutsummaryrefslogtreecommitdiff
path: root/portal
diff options
context:
space:
mode:
authorClombrong <cromblong@egregore.fun>2025-06-27 08:22:57 +0200
committerClombrong <cromblong@egregore.fun>2025-06-27 08:56:42 +0200
commit79d15a2baec54f10ba5114667d3d686982a90bee (patch)
treed1b68d76391d6057b282c86263a0126a704fad3b /portal
parent63f009280f29942ec2ea85176240e78becb2326b (diff)
feat(portal): make close a simple stanza
Diffstat (limited to 'portal')
-rw-r--r--portal/portal.mli6
-rw-r--r--portal/tcp/portal.ml4
-rw-r--r--portal/ws/portal.ml4
3 files changed, 8 insertions, 6 deletions
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 [<stream>] 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; _} =
- {|<close xmlns="|} ^ xmlns ^ {|" />|} |> string |> parse_xml |> signals |> Option.some |> p
+(** [close] is a [<close/>] stanza. *)
+let close = {|<close xmlns="|} ^ xmlns ^ {|" />|} |> string |> parse_xml |> signals
exception MalformedStanza of Markup.location * Markup.Error.t