summaryrefslogtreecommitdiffhomepage
path: root/WebSockets.hs
diff options
context:
space:
mode:
Diffstat (limited to 'WebSockets.hs')
-rw-r--r--WebSockets.hs15
1 files changed, 9 insertions, 6 deletions
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