From a6180f446dc97de56a2ed2e117c3be196d76f20b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 24 Apr 2017 14:04:55 -0400 Subject: also enable compression in server --- WebSockets.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'WebSockets.hs') 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 -- cgit v1.2.3