on master help sign in
Fix issue with withPingThread
4b16381flip111
wai-websockets/server.lhs+6
@@ -8,6 +8,8 @@ this example, keep the [reference](http://jaspervdj.be/websockets/reference)
8nearby to check out the functions we use.
8nearby to check out the functions we use.
9
9
10> {-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
10> {-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
11+> {-# LANGUAGE CPP #-}
12+> {-# OPTIONS_GHC -Wno-unused-top-binds #-} -- for numClients
11> import Data.Char (isPunctuation, isSpace)
13> import Data.Char (isPunctuation, isSpace)
12> import Data.Monoid (mappend)
14> import Data.Monoid (mappend)
13> import Data.Text (Text)
15> import Data.Text (Text)
@@ -99,7 +101,11 @@ stays alive on some browsers.
99
101
100> application state pending = do
102> application state pending = do
101> conn <- WS.acceptRequest pending
103> conn <- WS.acceptRequest pending
104+#if __GLASGOW_HASKELL__ >= 806
102> WS.withPingThread conn 30 (return ()) $ do
105> WS.withPingThread conn 30 (return ()) $ do
106+#else
107+> WS.forkPingThread conn 30
108+#endif
103
109
104When a client is successfully connected, we read the first message. This should
110When a client is successfully connected, we read the first message. This should
105be in the format of "Hi! I am Jasper", where Jasper is the requested username.
111be in the format of "Hi! I am Jasper", where Jasper is the requested username.