diff options
-rw-r--r-- | portal/tcp/portal_tcp.ml | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/portal/tcp/portal_tcp.ml b/portal/tcp/portal_tcp.ml index 3f6040d..6035f5d 100644 --- a/portal/tcp/portal_tcp.ml +++ b/portal/tcp/portal_tcp.ml @@ -8,6 +8,22 @@ let xmlns = "jabber:client" exception MalformedStanza of Markup.location * Markup.Error.t +let stanza_open ?from domain : (signal, sync) stream = + let stanza = + let attributes = + [(("", "to"), domain); (("", "version"), "1.0"); + (("http://www.w3.org/XML/1998/namespace", "lang"), "en"); + (("http://www.w3.org/2000/xmlns/", "xmlns"), xmlns); + (("http://www.w3.org/2000/xmlns/", "stream"), + "http://etherx.jabber.org/streams")] + in [`Start_element + (("http://etherx.jabber.org/streams", "stream"), + Option.fold + ~none:attributes + ~some:(fun jid -> (("", "from"), jid) :: attributes) + from)] + in stanza |> of_list + (** [xmpp_port domain] is the port where [domain]'s XMPP server is hosted. Currently, it falls back to 5222 (always), but should use SRV records in the near |