aboutsummaryrefslogtreecommitdiff
path: root/lib/stream.ml
diff options
context:
space:
mode:
authorClombrong <cromblong@egregore.fun>2025-06-29 19:57:29 +0200
committerClombrong <cromblong@egregore.fun>2025-06-29 19:57:29 +0200
commit2cda07bc71e90f0b0d8cea6792192b5af88b35f7 (patch)
tree41c1acbede071a2ee296b82486240277b7cd13ad /lib/stream.ml
parent305c0b127a15e4abd729cd923507330ddb5fd085 (diff)
feat(flesh): merge negotiate and initiate into connect function
Diffstat (limited to 'lib/stream.ml')
-rw-r--r--lib/stream.ml35
1 files changed, 0 insertions, 35 deletions
diff --git a/lib/stream.ml b/lib/stream.ml
index 6b46ed6..cc5ad92 100644
--- a/lib/stream.ml
+++ b/lib/stream.ml
@@ -81,38 +81,3 @@ let negotiate_feature (mandatory : bool) (feat : feature) (portal : Portal.t)
else Lwt.return_unit
| Mechanisms mechs -> authenticate mechs
| _ -> Lwt.return_unit
-
-(** [negotiate domain portal auth] is a promise containing the features supported by the
- XMPP server [portal], after eventual STARTTLS negotiation and authentication using
- the auth config [auth].
-
- This function should be called every time a stream needs to be reopened and stream
- negotiation takes place.
-
- Basically, it conforms to
- {{: https://datatracker.ietf.org/doc/html/rfc6120#section-4.3 }}. *)
-let negotiate
- (domain : string)
- (portal : Portal.t)
- (config : config) : features Lwt.t =
- (* Test if a specific features mandates a restart of the stream. *)
- let needs_restart = function
- | Mechanisms _ | STARTTLS -> true
- | _ -> false
- in
- let rec handle_features (f : features) : features Lwt.t =
- match f with
- | m :: mandatory, optional -> let* () = negotiate_feature true m portal config
- in if needs_restart m
- then start domain portal >>= handle_features
- else handle_features (mandatory, optional)
- | [], _ -> Lwt.return f
- in start domain portal >>= handle_features
-
-(** [initiate domain] initiates a stream with the XMPP server [domain]. *)
-let initiate (domain : string) (config : config) : (Portal.t * features) Lwt.t =
- let open Portal in
- let* p = connect domain
- in let+ features = negotiate domain p config
- in (p, features)
-