diff options
Diffstat (limited to 'portal/tcp')
-rw-r--r-- | portal/tcp/portal.ml | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/portal/tcp/portal.ml b/portal/tcp/portal.ml index 3477429..931cf93 100644 --- a/portal/tcp/portal.ml +++ b/portal/tcp/portal.ml @@ -2,15 +2,18 @@ open Lwt.Syntax open Lwt_unix open Markup -type t = (signal, async) stream * ((signal, sync) stream option -> unit) - type socket = file_descr +type t = { + stream : (signal, async) stream; + push : (signal, sync) stream option -> unit; + } + let xmlns = "http://etherx.jabber.org/streams" exception MalformedStanza of Markup.location * Markup.Error.t -let header ?from domain ((stream, push) : t) = +let header ?from domain ({stream; push} : t) = let stanza = let attributes = [(("", "to"), domain); (("", "version"), "1.0"); @@ -48,7 +51,7 @@ let header ?from domain ((stream, push) : t) = | None -> Lwt.fail_with "Invalid stream opening server-side." -let close (_, push) = [`End_element] |> Markup.of_list |> Option.some |> push +let close {push; _} = [`End_element] |> Markup.of_list |> Option.some |> push (** [xmpp_port domain] is the port where [domain]'s XMPP server is hosted. @@ -99,4 +102,4 @@ let connect (domain : string) : t Lwt.t = in Lwt.async (fun () -> let* _ = lwt_stream xml_stream |> Markup_lwt.write_xml |> iter send in Lwt_unix.close tcp_socket); - stream, push + {stream; push} |