From 0da19930bbb8144c52ebb1e65b3da66f031a3910 Mon Sep 17 00:00:00 2001 From: Ashwin Narayan Date: Thu, 21 Dec 2023 02:02:40 +0800 Subject: [PATCH] Added a way to manually send a Pong message (#217) --- src/Network/WebSockets/Connection.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Network/WebSockets/Connection.hs b/src/Network/WebSockets/Connection.hs index 9e87951..ec637b9 100644 --- a/src/Network/WebSockets/Connection.hs +++ b/src/Network/WebSockets/Connection.hs @@ -31,6 +31,7 @@ module Network.WebSockets.Connection , sendClose , sendCloseCode , sendPing + , sendPong , withPingThread , forkPingThread @@ -388,6 +389,10 @@ sendCloseCode conn code = sendPing :: WebSocketsData a => Connection -> a -> IO () sendPing conn = send conn . ControlMessage . Ping . toLazyByteString +-------------------------------------------------------------------------------- +-- | Send a pong +sendPong :: WebSocketsData a => Connection -> a -> IO () +sendPong conn = send conn . ControlMessage . Pong . toLazyByteString -------------------------------------------------------------------------------- -- | Forks a ping thread, sending a ping message every @n@ seconds over the