diff options
author | Clombrong <clombrong@egregore.fun> | 2025-05-08 22:33:47 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-05-08 22:33:47 +0200 |
commit | 9a23484b8f8f5c728e23130a8ee93a4ac2c97543 (patch) | |
tree | 00ad8e6d67ae341c3c2ad3a52f36ab5496d3d034 | |
parent | e2314545ef44b8b703692eb2471c3a2649e95cc1 (diff) |
feat: add to_frames function
i think the main scaffold of the function is mostly done
-rw-r--r-- | portal/lib/portal_ws.ml | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/portal/lib/portal_ws.ml b/portal/lib/portal_ws.ml index cadbf41..69e415e 100644 --- a/portal/lib/portal_ws.ml +++ b/portal/lib/portal_ws.ml @@ -91,7 +91,7 @@ let connect domain = \ <---- stream <---- filter_map <---- ws_stream <---- / *) let open Lwt_stream in let+ stream, ws_push = ws_endpoint domain >|= ws_stream in - let _streamed_stanzas, _push = create () in + let streamed_stanzas, push = create () in let open Stdlib.Buffer in let buf = create 1024 in (* NOTE: placeholder, ideally this should be the ~size of an XMPP stanza *) let _send_frame () = @@ -102,4 +102,9 @@ let connect domain = Some stanza_close |> ws_push; ws_push None; in - stream, ws_push + (* Consumes a stream of stanzas fragments into a series of frames sent to the WebSocket. *) + (* Right now... This doesn't do much. *) + let to_frames stream = + let+ _ = Lwt_stream.iter (fun x -> ws_push (Some x)) stream in ws_push None + in Lwt.async @@ (fun () -> to_frames streamed_stanzas); + stream, push |