diff options
-rw-r--r-- | portal/portal.mli | 6 | ||||
-rw-r--r-- | portal/tcp/portal.ml | 4 | ||||
-rw-r--r-- | portal/ws/portal.ml | 4 | ||||
-rw-r--r-- | test/hello.ml | 3 |
4 files changed, 9 insertions, 8 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 diff --git a/test/hello.ml b/test/hello.ml index 9b58de1..f9d429b 100644 --- a/test/hello.ml +++ b/test/hello.ml @@ -9,8 +9,7 @@ let program (p : Portal.t) config (features : Stream.features) = | Error (MalformedRequest, Some (_, text)) -> print_endline ("Malformed request: " ^ text) | Error _ -> print_endline "Error!" | Ok _ -> print_endline "Success!" - end; - Portal.close p + end let main = let config : Sasl.auth_config = { |