Rename ConnectionConfig record accessors

The old prefix didn't make sense any more with the renamed type.
This commit is contained in:
Joscha 2020-01-09 20:55:40 +00:00
parent a2668cdd2c
commit cd8ad59c2f

View file

@ -172,33 +172,33 @@ runWebsocketThread info =
parseAndSendReply value (ciAwaiting info) parseAndSendReply value (ciAwaiting info)
where where
connection = ciConnection info connection = ciConnection info
pingInterval = cdPingInterval $ ciDetails info pingInterval = confPingInterval $ ciDetails info
{- Running the Client monad -} {- Running the Client monad -}
-- | Configuration for the websocket connection. The websocket connection always -- | Configuration for the websocket connection. The websocket connection always
-- uses https. -- uses https.
data ConnectionConfig = ConnectionConfig data ConnectionConfig = ConnectionConfig
{ cdHost :: S.HostName { confHost :: S.HostName
, cdPort :: S.PortNumber , confPort :: S.PortNumber
, cdPath :: String , confPath :: String
, cdPingInterval :: Int , confPingInterval :: Int
} deriving (Show) } deriving (Show)
-- | A default configuration that points the bot to the room @&test@ at -- | A default configuration that points the bot to the room @&test@ at
-- <https://euphoria.io/room/test>. -- <https://euphoria.io/room/test>.
defaultConfig :: ConnectionConfig defaultConfig :: ConnectionConfig
defaultConfig = ConnectionConfig defaultConfig = ConnectionConfig
{ cdHost = "euphoria.io" { confHost = "euphoria.io"
, cdPort = 443 , confPort = 443
, cdPath = "/room/test/ws" , confPath = "/room/test/ws"
, cdPingInterval = 10 , confPingInterval = 10
} }
-- | @'withRoom' roomname config@ modifies the 'cdPath' of @config@ to point to -- | @'withRoom' roomname config@ modifies the 'cdPath' of @config@ to point to
-- the room @roomname@. -- the room @roomname@.
withRoom :: String -> ConnectionConfig -> ConnectionConfig withRoom :: String -> ConnectionConfig -> ConnectionConfig
withRoom room config = config{cdPath = "/room/" ++ room ++ "/ws"} withRoom room config = config{confPath = "/room/" ++ room ++ "/ws"}
--TODO: Catch IO exceptions that occur when a connection could not be created --TODO: Catch IO exceptions that occur when a connection could not be created
-- | Execute a 'Client'. -- | Execute a 'Client'.
@ -213,7 +213,7 @@ withRoom room config = config{cdPath = "/room/" ++ room ++ "/ws"}
runClient :: ConnectionConfig -> Client e a -> IO (Either (ClientException e) a) runClient :: ConnectionConfig -> Client e a -> IO (Either (ClientException e) a)
runClient details (Client stack) = runClient details (Client stack) =
S.withSocketsDo $ S.withSocketsDo $
WSS.runSecureClient (cdHost details) (cdPort details) (cdPath details) $ \connection -> do WSS.runSecureClient (confHost details) (confPort details) (confPath details) $ \connection -> do
awaiting <- newTVarIO Map.empty awaiting <- newTVarIO Map.empty
eventChan <- newTChanIO eventChan <- newTChanIO
packetId <- newTVarIO 0 packetId <- newTVarIO 0