mqtt-hs-1.0.0: A MQTT client library.

CopyrightLukas Braun 2014-2016
LicenseGPL-3
Maintainerkoomi+mqtt@hackerspace-bamberg.de
Safe HaskellNone
LanguageHaskell2010

Network.MQTT.Internal

Contents

Description

MQTT Internals.

Use with care and expected changes.

Synopsis

User interaction

data Config Source #

The various options when establishing a connection. See below for available accessors.

Constructors

Config 

Fields

data Terminated Source #

Reasons for why the connection was terminated.

Constructors

ParseFailed [String] String

at the context in [String] with the given message.

ConnectFailed ConnectError 
UserRequested

disconnect was called

newtype Commands Source #

The communication channel used by publish, subscribe, etc.

Constructors

Cmds 

Fields

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.

send :: SingI t => Config -> Message t -> IO () Source #

Tell the mainLoop to send the given Message.

await :: SingI t => Config -> MVar (Message t) -> Maybe MsgID -> IO AwaitMessage Source #

Tell the MQTT instance to place the next Message of correct MsgType and MsgID (if present) into the MVar.

stopWaiting :: Config -> AwaitMessage -> IO () Source #

Stop waiting for the described Message.

sendAwait :: (SingI t, SingI r) => Config -> Message t -> SMsgType r -> IO (Message r) Source #

Execute the common pattern of sending a message and awaiting a response in a safe, non-racy way. The message message is retransmitted if no response has been received after cResendTimeout seconds, with exponential backoff for further retransmissions

An incoming message is considered a response if it is of the requested type and the MsgIDs match (if present).

Main loop

data MqttState Source #

Internal state for the main loop

Constructors

MqttState 

Fields

data Input Source #

Input for the main loop

parseBytes :: Monad m => ByteString -> StateT MqttState m (Maybe Input) Source #

Parse the given ByteString and update the current MqttState.

Returns Nothing if more input is needed.

Misc