diff options
author | Clombrong <cromblong@egregore.fun> | 2025-08-14 23:46:52 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-08-15 00:13:57 +0200 |
commit | e4e8a81f030dc599b1d5dc84b9725667c3872124 (patch) | |
tree | a7b14daa695e1d5521b07d0fb5a3ff73a225b62b | |
parent | 1283666e6cc07c3149667dfb3218a0dbae62abd6 (diff) |
feat(session): add t type for session data
-rw-r--r-- | lib/session.ml | 9 | ||||
-rw-r--r-- | test/hello.ml | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/session.ml b/lib/session.ml index d0c2754..f4d5f94 100644 --- a/lib/session.ml +++ b/lib/session.ml @@ -14,6 +14,11 @@ type state = (* TCP/WebSocket connected, not connected in XMPP-land *) | Connected of Portal.t * step +type t = { + state : state signal; + update : state -> unit; + } + (** [create domain config] is a promise containing a signal representing the portal connected to the XMPP server located at [domain], and all its supported features. @@ -22,7 +27,7 @@ type state = Basically, it conforms to {{: https://datatracker.ietf.org/doc/html/rfc6120#section-4.3 }}, and gets the Portal in a "ready" state. *) -let create (domain : string) (config : config) = +let create (domain : string) (config : config) : t Lwt.t = let needs_restart = function | Feature.Mechanisms _ | STARTTLS -> true | _ -> false @@ -53,4 +58,4 @@ let create (domain : string) (config : config) = in update (Connected (portal, next_state)) | _ -> Lwt.return_unit) state >|= S.keep; - in state, update + in { state; update } diff --git a/test/hello.ml b/test/hello.ml index e91f65f..005db94 100644 --- a/test/hello.ml +++ b/test/hello.ml @@ -16,7 +16,7 @@ let main = } in let waiter, wakener = Lwt.wait () in - try%lwt let* state, update = create config.sasl.jid.domainpart config in + try%lwt let* { state; update } = create config.sasl.jid.domainpart config in S.map (function | Connected (portal, Logged_in _) -> portal.push None; Lwt.wakeup wakener () |