mqtt-hs-0.2.0: A MQTT client library.

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

Network.MQTT.Types

Contents

Description

Types representing MQTT messages.

Synopsis

Messages

data Message t Source

A MQTT message, indexed by the type of the message (MsgType).

Constructors

Message 

data SomeMessage where Source

Any message, hiding the index.

Constructors

SomeMessage :: Message t -> SomeMessage 

data MqttHeader Source

Fixed header required in every message.

Constructors

Header 

Fields

dup :: Bool

Has this message been sent before?

qos :: QoS

Quality of Service-level

retain :: Bool

Should the broker retain the message for future subscribers?

Message bodies

data Connect Source

The fields of a CONNECT message.

Constructors

Connect 

Fields

cleanSession :: Bool

Should the server forget subscriptions and other state on disconnects?

will :: Maybe Will

Optional Will message.

clientID :: MqttText

Client ID used by the server to identify clients.

username :: Maybe MqttText

Optional username used for authentication.

password :: Maybe MqttText

Optional password used for authentication.

keepAlive :: Word16

Maximum interval (in seconds) in which a message must be sent. 0 means no limit.

Instances

newtype ConnAck Source

The response to a CONNECT. Anything other than 0 means the broker refused the connection (details).

Constructors

ConnAck 

Fields

returnCode :: Word8
 

Instances

data Publish Source

The fields of a PUBLISH message.

Constructors

Publish 

Fields

topic :: Topic

The Topic to which the message should be published.

pubMsgID :: Maybe MsgID

MsgID of the message if QoS > NoConfirm.

payload :: ByteString

The content that will be published.

Instances

data Subscribe Source

The fields of a SUBSCRIBE message.

Constructors

Subscribe 

Fields

subscribeMsgID :: MsgID
 
subTopics :: [(Topic, QoS)]

The Topics and corresponding requested QoS.

data SubAck Source

The fields of a SUBACK message.

Constructors

SubAck 

Fields

subAckMsgID :: MsgID
 
granted :: [QoS]

The QoS granted for each Topic in the order they were sent in the SUBSCRIBE.

Instances

data Unsubscribe Source

The fields of a UNSUBSCRIBE message.

Constructors

Unsubscribe 

Fields

unsubMsgID :: MsgID
 
unsubTopics :: [Topic]

The Topics from which the client should be unsubscribed.

newtype SimpleMsg Source

Any message body that consists only of a MsgID.

Constructors

SimpleMsg 

Fields

msgID :: MsgID
 

Miscellaneous

data Will Source

A Will message is published by the broker if a client disconnects without sending a DISCONNECT.

Constructors

Will 

Fields

wRetain :: Bool
 
wQoS :: QoS
 
wTopic :: Topic
 
wMsg :: MqttText
 

Instances

data QoS Source

The different levels of QoS

Constructors

NoConfirm

Fire and forget

Confirm

Acknowledged delivery (repeat until ack)

Handshake

Assured delivery (four-step handshake)

Instances

getMsgID :: MessageBody t -> Maybe MsgID Source

Get the message ID of any message, if it exists.

data Topic Source

A topic is a "hierarchical name space that defines a taxonomy of information sources for which subscribers can register an interest."

See here for more information on topics.

matches :: Topic -> Topic -> Bool Source

Check if one of the Topics matches the other.

newtype MqttText Source

MQTT uses length-prefixed UTF-8 as text encoding.

Constructors

MqttText 

Fields

text :: Text
 

Message types

toMsgType :: Message t -> MsgType Source

Determine the MsgType of a Message.

Singletons

Singletons are used to build a bridge between the type and value level. See the singletons package for more information.

You do not have to use or understand these in order to use this library, they are mostly used internally to get better guarantees about the flow of Messages.

toSMsgType :: Message t -> SMsgType t Source

Determine the singleton SMsgType of a Message.

type SMsgType z = Sing z Source

data family Sing a

Instances

SDecide k (KProxy k) => TestEquality k (Sing k) 
data Sing Bool where 
data Sing Ordering where 
data Sing Nat where 
data Sing Symbol where 
data Sing () where 
data Sing MsgType where 
data Sing [a0] where 
data Sing (Maybe a0) where 
data Sing (TyFun k1 k2 -> *) = SLambda {} 
data Sing (Either a0 b0) where 
data Sing ((,) a0 b0) where 
data Sing ((,,) a0 b0 c0) where 
data Sing ((,,,) a0 b0 c0 d0) where 
data Sing ((,,,,) a0 b0 c0 d0 e0) where 
data Sing ((,,,,,) a0 b0 c0 d0 e0 f0) where 
data Sing ((,,,,,,) a0 b0 c0 d0 e0 f0 g0) where