Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/cannon/cannon.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ library
, wai-utilities >= 0.11
, wai-websockets >= 3.0
, warp >= 3.0
, websockets >= 0.9
, websockets >= 0.11

executable cannon
main-is: src/Main.hs
Expand Down
8 changes: 6 additions & 2 deletions services/cannon/src/Cannon/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import Network.Wai.Utilities.Server
import Network.Wai.Utilities.Swagger
import Network.Wai.Handler.Warp hiding (run)
import Network.Wai.Handler.WebSockets
import Network.WebSockets (defaultConnectionOptions)
import Prelude hiding (head)
import System.Logger.Class hiding (Error)
import System.Random.MWC (createSystemRandom)

import qualified Cannon.Dict as D
import qualified Data.Metrics.Middleware as Metrics
import qualified Network.Wai.Middleware.Gzip as Gzip
import qualified Network.WebSockets as Ws
import qualified System.Logger as Logger

run :: Opts -> IO ()
Expand Down Expand Up @@ -124,8 +124,12 @@ await :: UserId ::: ConnId ::: Maybe ClientId ::: Request -> Cannon Response
await (u ::: a ::: c ::: r) = do
l <- logger
e <- wsenv
case websocketsApp defaultConnectionOptions (wsapp (mkKey u a) c l e) r of
case websocketsApp wsoptions (wsapp (mkKey u a) c l e) r of
Nothing -> return $ errorRs status426 "request-error" "websocket upgrade required"
Just rs -> return rs
where
status426 = mkStatus 426 "Upgrade Required"
wsoptions = Ws.defaultConnectionOptions
{ Ws.connectionCompressionOptions = Ws.PermessageDeflateCompression Ws.defaultPermessageDeflate
, Ws.connectionStrictUnicode = True
}
1 change: 1 addition & 0 deletions services/cannon/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ extra-deps:
- data-timeout-0.3
- text-latin1-0.3
- text-printer-0.5
- websockets-0.11.1.0
extra-package-dbs: []