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.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 :: SingI t => 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?

setDup :: Message t -> Message t Source #

Set the dup flag to True.

Message body

data MessageBody t where Source #

The body of a MQTT message, indexed by the type of the message (MsgType).

Constructors

Connect :: {..} -> MessageBody CONNECT 

Fields

ConnAck :: {..} -> MessageBody CONNACK 

Fields

Publish :: {..} -> MessageBody PUBLISH 

Fields

PubAck :: {..} -> MessageBody PUBACK 

Fields

PubRec :: {..} -> MessageBody PUBREC 

Fields

PubRel :: {..} -> MessageBody PUBREL 

Fields

PubComp :: {..} -> MessageBody PUBCOMP 

Fields

Subscribe :: {..} -> MessageBody SUBSCRIBE 

Fields

SubAck :: {..} -> MessageBody SUBACK 

Fields

Unsubscribe :: {..} -> MessageBody UNSUBSCRIBE 

Fields

UnsubAck :: {..} -> MessageBody UNSUBACK 

Fields

PingReq :: MessageBody PINGREQ 
PingResp :: MessageBody PINGRESP 
Disconnect :: MessageBody DISCONNECT 

Miscellaneous

data Will Source #

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

Constructors

Will 

Fields

Instances

Eq Will Source # 

Methods

(==) :: Will -> Will -> Bool #

(/=) :: Will -> Will -> Bool #

Show Will Source # 

Methods

showsPrec :: Int -> Will -> ShowS #

show :: Will -> String #

showList :: [Will] -> ShowS #

data QoS Source #

The different levels of QoS

Constructors

NoConfirm

Fire and forget, message will be published at most once.

Confirm

Acknowledged delivery, message will be published at least once.

Handshake

Assured delivery, message will be published exactly once.

Instances

Enum QoS Source # 

Methods

succ :: QoS -> QoS #

pred :: QoS -> QoS #

toEnum :: Int -> QoS #

fromEnum :: QoS -> Int #

enumFrom :: QoS -> [QoS] #

enumFromThen :: QoS -> QoS -> [QoS] #

enumFromTo :: QoS -> QoS -> [QoS] #

enumFromThenTo :: QoS -> QoS -> QoS -> [QoS] #

Eq QoS Source # 

Methods

(==) :: QoS -> QoS -> Bool #

(/=) :: QoS -> QoS -> Bool #

Ord QoS Source # 

Methods

compare :: QoS -> QoS -> Ordering #

(<) :: QoS -> QoS -> Bool #

(<=) :: QoS -> QoS -> Bool #

(>) :: QoS -> QoS -> Bool #

(>=) :: QoS -> QoS -> Bool #

max :: QoS -> QoS -> QoS #

min :: QoS -> QoS -> QoS #

Show QoS Source # 

Methods

showsPrec :: Int -> QoS -> ShowS #

show :: QoS -> String #

showList :: [QoS] -> ShowS #

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 the specification for more details.

A topic can be inspected by using the matches function or after using getLevels, e.g.:

f1 topic
  | topic `matches` "mqtt/hs/example" = putStrLn "example"
  | topic `matches` "mqtt/hs/#" = putStrLn "wildcard"

f2 topic = case getLevels topic of
             ["mqtt", "hs", "example"] -> putStrLn "example"
             "mqtt" : "hs" : _ -> putStrLn "wildcard"

Instances

matches :: Topic -> Topic -> Bool Source #

Check if one of the Topics matches the other, taking wildcards into consideration.

getLevels :: Topic -> [Text] Source #

Split a topic into its individual levels.

fromLevels :: [Text] -> Topic Source #

Create a Topic from its individual levels.

newtype MqttText Source #

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

Constructors

MqttText 

Fields

toConnectError :: Word8 -> ConnectError Source #

Convert a return code to a ConnectError.

Message types

data MsgType Source #

The various types of messages.

Instances

Enum MsgType Source # 
Eq MsgType Source # 

Methods

(==) :: MsgType -> MsgType -> Bool #

(/=) :: MsgType -> MsgType -> Bool #

Ord MsgType Source # 
Show MsgType Source # 
SingI MsgType CONNECT Source # 

Methods

sing :: Sing CONNECT a #

SingI MsgType CONNACK Source # 

Methods

sing :: Sing CONNACK a #

SingI MsgType PUBLISH Source # 

Methods

sing :: Sing PUBLISH a #

SingI MsgType PUBACK Source # 

Methods

sing :: Sing PUBACK a #

SingI MsgType PUBREC Source # 

Methods

sing :: Sing PUBREC a #

SingI MsgType PUBREL Source # 

Methods

sing :: Sing PUBREL a #

SingI MsgType PUBCOMP Source # 

Methods

sing :: Sing PUBCOMP a #

SingI MsgType SUBSCRIBE Source # 

Methods

sing :: Sing SUBSCRIBE a #

SingI MsgType SUBACK Source # 

Methods

sing :: Sing SUBACK a #

SingI MsgType UNSUBSCRIBE Source # 

Methods

sing :: Sing UNSUBSCRIBE a #

SingI MsgType UNSUBACK Source # 

Methods

sing :: Sing UNSUBACK a #

SingI MsgType PINGREQ Source # 

Methods

sing :: Sing PINGREQ a #

SingI MsgType PINGRESP Source # 

Methods

sing :: Sing PINGRESP a #

SingI MsgType DISCONNECT Source # 

Methods

sing :: Sing DISCONNECT a #

SDecide MsgType (KProxy MsgType) Source # 

Methods

(%~) :: Sing (KProxy MsgType) a -> Sing (KProxy MsgType) b -> Decision ((KProxy MsgType :~: a) b) #

SingKind MsgType (KProxy MsgType) Source # 

Associated Types

type DemoteRep (KProxy MsgType) (kparam :: KProxy (KProxy MsgType)) :: * #

data Sing MsgType Source # 
type DemoteRep MsgType (KProxy MsgType) Source # 

toMsgType :: SingI t => 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 :: SingI t => Message t -> SMsgType t Source #

Determine the singleton SMsgType of a Message.

type SMsgType = (Sing :: MsgType -> Type) Source #

withSomeSingI :: MsgType -> (forall t. SingI t => SMsgType t -> r) -> r Source #

Helper to generate both an implicit and explicit singleton.

data family Sing k (a :: k) :: * #

The singleton kind-indexed data family.

Instances

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