diff options
-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 |