diff --git a/yesod-websockets/ChangeLog.md b/yesod-websockets/ChangeLog.md index babc6cdd..110b0f3f 100644 --- a/yesod-websockets/ChangeLog.md +++ b/yesod-websockets/ChangeLog.md @@ -1,3 +1,6 @@ +## 0.3.0.3 +* Removed the use of the deprecated forkPingThread and replaced it with the recommended withPingThread. [#1700](https://github.com/yesodweb/yesod/pull/1700) + ## 0.3.0.2 * `sendClose` and `sendPing` correctly find the `Connection` from `WebSocketsT` diff --git a/yesod-websockets/Yesod/WebSockets.hs b/yesod-websockets/Yesod/WebSockets.hs index 8512b0ba..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 + let app = runInIO $ runReaderT inner conn +#if MIN_VERSION_websockets(0,12,6) + WS.withPingThread conn 30 (pure ()) $ app +#else WS.forkPingThread conn 30 - runInIO $ runReaderT inner conn) + app +#endif + ) src sink diff --git a/yesod-websockets/yesod-websockets.cabal b/yesod-websockets/yesod-websockets.cabal index eafe5bc6..8d0d9da7 100644 --- a/yesod-websockets/yesod-websockets.cabal +++ b/yesod-websockets/yesod-websockets.cabal @@ -1,5 +1,5 @@ name: yesod-websockets -version: 0.3.0.2 +version: 0.3.0.3 synopsis: WebSockets support for Yesod homepage: https://github.com/yesodweb/yesod license: MIT