aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClombrong <clombrong@egregore.fun>2025-04-24 18:31:27 +0200
committerClombrong <cromblong@egregore.fun>2025-04-24 18:31:27 +0200
commit1f9cc8a538e6cdc4842b54d3b4cfd6c51f853cfc (patch)
tree276e8e37ada9a2c0972ba45bb62d196388cc274b
parent94dc992612350121a3b51614f6e3e382d8795ae2 (diff)
feat: test a real XMPP connection
-rw-r--r--portal/test/js/websockets_hello.ml26
1 files changed, 11 insertions, 15 deletions
diff --git a/portal/test/js/websockets_hello.ml b/portal/test/js/websockets_hello.ml
index fa47965..76b70e4 100644
--- a/portal/test/js/websockets_hello.ml
+++ b/portal/test/js/websockets_hello.ml
@@ -17,19 +17,15 @@ let rec run t =
let () =
run @@
- let* server = Portal_ws.ws_endpoint "telepath.im" in
+ let* ws = Portal_ws.ws_endpoint "squarebowl.club" in
let stream, push =
- (* Echo is a websocket that... echoes you stuff. *)
- Portal_ws.ws_stream "wss://echo.websocket.org" in
- push (Some "great text");
- push (Some "other text");
- push (Some "yet another text");
- push (Some "BYE");
- let+ _ = Lwt_stream.iter
- (fun greetings ->
- match greetings with
- (* When the websocket sends "BYE", we close. *)
- | "BYE" -> print_endline "CLOSING BYE"; push None
- | hello -> print_endline ("> " ^ hello))
- stream
- in print_endline server
+ Portal_ws.ws_stream ws in
+ push (Some "malformed");
+ let+ stanzas = stream
+ |> Lwt_stream.map
+ (fun stanza ->
+ match stanza with
+ | {|<close xmlns='urn:ietf:params:xml:ns:xmpp-framing'/>|} -> push None; stanza
+ | stanza -> stanza)
+ |> Lwt_stream.to_list
+ in List.map (fun x -> " >>> " ^ x) stanzas |> String.concat "\n" |> print_endline