Skip to content

Commit

Permalink
rename hooks to start with on
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Jan 26, 2024
1 parent 3d98ada commit fb24cd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Network/WebSockets/Typed/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
}

Expand All @@ -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?
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/Network/WebSockets/Typed/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
}

--
Expand All @@ -33,7 +33,7 @@ defaultOptions =
{ handlePendingConnection = (fmap Just) . WS.acceptRequest,
pingPongOptions = return,
messageLimit = 10000,
handleException = \_ _ -> return ()
onHandleException = \_ _ -> return ()
}

class ClientConnection a where
Expand All @@ -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)
Expand Down

0 comments on commit fb24cd6

Please sign in to comment.