From 595ee70386d63c760ecab07c876a11b4cb17fd9d Mon Sep 17 00:00:00 2001 From: Christopher Reichert Date: Sun, 14 Dec 2014 14:05:15 -0600 Subject: [PATCH 1/4] Keep client connections alive using Network.WebSocket.forkPingThread. --- yesod-websockets/Yesod/WebSockets.hs | 1 + yesod-websockets/yesod-websockets.cabal | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/yesod-websockets/Yesod/WebSockets.hs b/yesod-websockets/Yesod/WebSockets.hs index 3df66e81..38f3215b 100644 --- a/yesod-websockets/Yesod/WebSockets.hs +++ b/yesod-websockets/Yesod/WebSockets.hs @@ -53,6 +53,7 @@ webSockets inner = do (WaiWS.getRequestHead req) (\pconn -> do conn <- WS.acceptRequest pconn + WS.forkPingThread conn 30 runInIO $ runReaderT inner conn) src sink diff --git a/yesod-websockets/yesod-websockets.cabal b/yesod-websockets/yesod-websockets.cabal index 4112b6a2..b801bbb4 100644 --- a/yesod-websockets/yesod-websockets.cabal +++ b/yesod-websockets/yesod-websockets.cabal @@ -1,6 +1,3 @@ --- Initial yesod-websockets.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/ - name: yesod-websockets version: 0.2.0 synopsis: WebSockets support for Yesod @@ -22,7 +19,7 @@ library , wai , wai-websockets >= 2.1 - , websockets >= 0.8 + , websockets >= 0.9.2 , transformers >= 0.2 , yesod-core >= 1.4 , monad-control >= 0.3 From e7a5b48898b46688a4e1634469b4b5ee6a52afee Mon Sep 17 00:00:00 2001 From: Christopher Reichert Date: Sun, 14 Dec 2014 14:13:06 -0600 Subject: [PATCH 2/4] Bump yesod-websockets version. --- yesod-websockets/yesod-websockets.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yesod-websockets/yesod-websockets.cabal b/yesod-websockets/yesod-websockets.cabal index b801bbb4..c923139c 100644 --- a/yesod-websockets/yesod-websockets.cabal +++ b/yesod-websockets/yesod-websockets.cabal @@ -1,5 +1,5 @@ name: yesod-websockets -version: 0.2.0 +version: 0.2.1 synopsis: WebSockets support for Yesod description: WebSockets support for Yesod homepage: https://github.com/yesodweb/yesod From fbc6c9fc13622da1386c47f501e1daa71a96d3dc Mon Sep 17 00:00:00 2001 From: Christopher Reichert Date: Sun, 14 Dec 2014 14:44:24 -0600 Subject: [PATCH 3/4] Fix if then statement layout in Scaffolder. Fixes the Travis build error: ``` Scaffolding/Scaffolder.hs:99:34: Unexpected semi-colons in conditional: if isBare; then LT.replace "cd PROJECTNAME && " ""; else LT.replace "PROJECTNAME" (LT.pack project) Perhaps you meant to use -XDoAndIfThenElse? ``` --- yesod-bin/Scaffolding/Scaffolder.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yesod-bin/Scaffolding/Scaffolder.hs b/yesod-bin/Scaffolding/Scaffolder.hs index 0f38fcc4..3f12291c 100644 --- a/yesod-bin/Scaffolding/Scaffolder.hs +++ b/yesod-bin/Scaffolding/Scaffolder.hs @@ -97,7 +97,7 @@ scaffold isBare = do Right backend -> runResourceT $ yield (backendBS backend) $$ sink let projectnameReplacer = if isBare - then LT.replace "cd PROJECTNAME && " "" - else LT.replace "PROJECTNAME" (LT.pack project) + then LT.replace "cd PROJECTNAME && " "" + else LT.replace "PROJECTNAME" (LT.pack project) TLIO.putStr $ projectnameReplacer $ renderTextUrl undefined $(textFile "input/done.cg") From c98fbb0596de94e5690fecdc42e791f8c04d66d9 Mon Sep 17 00:00:00 2001 From: Christopher Reichert Date: Sun, 14 Dec 2014 16:11:25 -0600 Subject: [PATCH 4/4] Depend on websockets >= 0.9 in yesod-websockets.cabal. The forkPingThread function was added in version 0.9 of websockets. Complimentary fix to #889. --- yesod-websockets/yesod-websockets.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yesod-websockets/yesod-websockets.cabal b/yesod-websockets/yesod-websockets.cabal index c923139c..434ea821 100644 --- a/yesod-websockets/yesod-websockets.cabal +++ b/yesod-websockets/yesod-websockets.cabal @@ -19,7 +19,7 @@ library , wai , wai-websockets >= 2.1 - , websockets >= 0.9.2 + , websockets >= 0.9 , transformers >= 0.2 , yesod-core >= 1.4 , monad-control >= 0.3