From c00d1e1aa8c0ad2d022e9548a171138c21352883 Mon Sep 17 00:00:00 2001 From: David Burkett Date: Wed, 4 Nov 2020 21:46:00 -0500 Subject: [PATCH] Use forkPingThread if websockets is less than 0.12.6.0 --- yesod-websockets/Yesod/WebSockets.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/yesod-websockets/Yesod/WebSockets.hs b/yesod-websockets/Yesod/WebSockets.hs index e4740266..94eede27 100644 --- a/yesod-websockets/Yesod/WebSockets.hs +++ b/yesod-websockets/Yesod/WebSockets.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} module Yesod.WebSockets @@ -117,8 +118,14 @@ webSocketsOptionsWith wsConnOpts buildAr inner = do rhead (\pconn -> do conn <- WS.acceptRequestWith pconn ar - WS.withPingThread conn 30 (pure ()) $ - runInIO $ runReaderT inner conn) + let app = runInIO $ runReaderT inner conn +#if MIN_VERSION_websockets(0,12,6) + WS.withPingThread conn 30 (pure ()) $ app +#else + WS.forkPingThread conn 30 + app +#endif + ) src sink