diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-26 00:12:19 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-26 00:12:19 +0200 |
commit | 98d970d322957862d4e2b7b899581c53d17aedd8 (patch) | |
tree | c8cf40be76c2e659dd5e277c84def94379441d4e | |
parent | c9749a3d532d0998468b7d2f3622538e8adcdb4d (diff) |
feat(portal_tcp): add stanza_open
-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 |