From fb24cd6fd7e32a361fef2be7883810c329fab10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Fri, 26 Jan 2024 14:29:15 +0000 Subject: [PATCH] rename hooks to start with on --- src/Network/WebSockets/Typed/Client.hs | 6 +++--- src/Network/WebSockets/Typed/Server.hs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Network/WebSockets/Typed/Client.hs b/src/Network/WebSockets/Typed/Client.hs index c34b954..9ad825e 100644 --- a/src/Network/WebSockets/Typed/Client.hs +++ b/src/Network/WebSockets/Typed/Client.hs @@ -24,7 +24,7 @@ data Options = Options { headers :: WS.Headers, messageLimit :: Int, staminaSettings :: Stamina.RetrySettings, - staminaRetry :: Stamina.RetryStatus -> IO (), + onStaminaRetry :: Stamina.RetryStatus -> IO (), onShutdown :: WS.Connection -> IO () } @@ -38,7 +38,7 @@ defaultOptions = { Stamina.maxTime = Nothing, Stamina.maxAttempts = Nothing }, - staminaRetry = const $ return (), + onStaminaRetry = const $ return (), onShutdown = \connection -> -- TODO: drain the message queues -- TODO: if there was an exception related to socket, we need to handle it? @@ -50,7 +50,7 @@ run uriBS options app receiveApp = do (isSecure, host, port, path) <- Utils.parseURI uriBS Stamina.retry (staminaSettings options) $ \retryStatus -> do when (isJust $ Stamina.lastException retryStatus) $ - staminaRetry options retryStatus + onStaminaRetry options retryStatus if isSecure then Wuss.runSecureClientWith (unpack host) (fromIntegral port) (unpack path) connectionOptions (headers options) (go retryStatus) else WS.runClientWith (unpack host) (fromIntegral port) (unpack path) connectionOptions (headers options) (go retryStatus) diff --git a/src/Network/WebSockets/Typed/Server.hs b/src/Network/WebSockets/Typed/Server.hs index ee13319..1ce5502 100644 --- a/src/Network/WebSockets/Typed/Server.hs +++ b/src/Network/WebSockets/Typed/Server.hs @@ -23,7 +23,7 @@ data Options a = Options { handlePendingConnection :: (ClientConnection a) => WS.PendingConnection -> IO (Maybe a), pingPongOptions :: WS.PingPongOptions -> IO WS.PingPongOptions, messageLimit :: Int, - handleException :: WS.PendingConnection -> SomeException -> IO () + onHandleException :: WS.PendingConnection -> SomeException -> IO () } -- @@ -33,7 +33,7 @@ defaultOptions = { handlePendingConnection = (fmap Just) . WS.acceptRequest, pingPongOptions = return, messageLimit = 10000, - handleException = \_ _ -> return () + onHandleException = \_ _ -> return () } class ClientConnection a where @@ -55,7 +55,7 @@ run uriBS options app receiveApp = do WS.runServerWithOptions serverOptions (application pingpongOpts) where application :: PingPong.PingPongOptions -> WS.ServerApp - application pingpongOpts pendingConnection = handle (handleException options pendingConnection) $ do + application pingpongOpts pendingConnection = handle (onHandleException options pendingConnection) $ do maybeClient <- handlePendingConnection options pendingConnection for_ maybeClient $ \client -> PingPong.withPingPong pingpongOpts (getConnection client) $ \_ -> Session.run (messageLimit options) (getConnection client) (app client) (receiveApp client)