Copyright | Lukas Braun 2014-2016 |
---|---|
License | GPL-3 |
Maintainer | koomi+mqtt@hackerspace-bamberg.de |
Safe Haskell | None |
Language | Haskell2010 |
An MQTT client library.
- run :: Config -> IO Terminated
- data Terminated
- disconnect :: Config -> IO ()
- data Config
- defaultConfig :: Commands -> TChan (Message PUBLISH) -> Config
- data Commands
- mkCommands :: IO Commands
- cHost :: Config -> HostName
- cPort :: Config -> PortNumber
- cClean :: Config -> Bool
- cWill :: Config -> Maybe Will
- cUsername :: Config -> Maybe Text
- cPassword :: Config -> Maybe Text
- cKeepAlive :: Config -> Maybe Word16
- cClientID :: Config -> Text
- cLogDebug :: Config -> String -> IO ()
- cPublished :: Config -> TChan (Message PUBLISH)
- cCommands :: Config -> Commands
- cInputBufferSize :: Config -> Int
- subscribe :: Config -> [(Topic, QoS)] -> IO [QoS]
- unsubscribe :: Config -> [Topic] -> IO ()
- publish :: Config -> QoS -> Bool -> Topic -> ByteString -> IO ()
- module Network.MQTT.Types
Setup
run :: Config -> IO Terminated Source #
Connect to the configured broker, write received Publish
messages to the
cPublished
channel and handle commands from the cCommands
channel.
Exceptions are propagated.
data Terminated Source #
Reasons for why the connection was terminated.
ParseFailed [String] String | at the context in |
ConnectFailed ConnectError | |
UserRequested |
|
disconnect :: Config -> IO () Source #
Close the connection after sending a Disconnect
message.
See also: Will
The various options when establishing a connection. See below for available accessors.
defaultConfig :: Commands -> TChan (Message PUBLISH) -> Config Source #
Defaults for Config
, connects to a server running on
localhost.
mkCommands :: IO Commands Source #
Create a new Commands
channel.
There should be one channel per MQTT connection. It might be reused by subsequent connections, but never by multiple connections concurrently.
Config accessors
cPort :: Config -> PortNumber Source #
Port of the broker.
cClean :: Config -> Bool Source #
Should the server forget subscriptions and other state on disconnects?
cPublished :: Config -> TChan (Message PUBLISH) Source #
The channel received Publish
messages are written to.
cInputBufferSize :: Config -> Int Source #
Maximum number of bytes read from the network at once.
Subscribing and publishing
Reexports
module Network.MQTT.Types