summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Server.hs2
-rw-r--r--WebSockets.hs15
2 files changed, 10 insertions, 7 deletions
diff --git a/Server.hs b/Server.hs
index 5467fbe..527ac02 100644
--- a/Server.hs
+++ b/Server.hs
@@ -93,7 +93,7 @@ server o = runSettings settings . app o =<< newServerState
defaultSettings
app :: ServerOpts -> TVar ServerState -> Application
-app o ssv = websocketsOr WS.defaultConnectionOptions (websocketApp o ssv) webapp
+app o ssv = websocketsOr connectionOptions (websocketApp o ssv) webapp
where
webapp _ respond = respond $
responseLBS status400 [] "Not a WebSocket request"
diff --git a/WebSockets.hs b/WebSockets.hs
index 6231298..c463c28 100644
--- a/WebSockets.hs
+++ b/WebSockets.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE OverloadedStrings, DeriveGeneric, GeneralizedNewtypeDeriving, FlexibleContexts, FlexibleInstances #-}
module WebSockets (
+ connectionOptions,
runClientApp,
clientApp,
protocolError,
@@ -29,9 +30,16 @@ import qualified Data.ByteString.Lazy as L
import Data.List
import Data.Monoid
+-- | Enable compression.
+connectionOptions :: ConnectionOptions
+connectionOptions = defaultConnectionOptions
+ { connectionCompressionOptions =
+ PermessageDeflateCompression defaultPermessageDeflate
+ }
+
runClientApp :: ClientApp () -> IO ()
runClientApp app = catchJust catchconnclosed
- (runClientWith "localhost" 8081 "/" connoptions [] app)
+ (runClientWith "localhost" 8081 "/" connectionOptions [] app)
(\_ -> return ())
where
-- For some reason, runClient throws ConnectionClosed
@@ -39,11 +47,6 @@ runClientApp app = catchJust catchconnclosed
catchconnclosed ConnectionClosed = Just ()
catchconnclosed _ = Nothing
- connoptions = defaultConnectionOptions
- { connectionCompressionOptions =
- PermessageDeflateCompression defaultPermessageDeflate
- }
-
-- | Make a client that sends and receives LogMessages over a websocket.
clientApp
:: Mode