diff options
-rw-r--r-- | portal/test/js/websockets_hello.ml | 26 |
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 |