| Copyright | Lukas Braun 2014 |
|---|---|
| License | GPL-3 |
| Maintainer | koomi+mqtt@hackerspace-bamberg.de |
| Safe Haskell | None |
| Language | Haskell2010 |
MQTT.Types
Description
Types representing MQTT messages.
- data Message t = Message {
- header :: MqttHeader
- body :: MessageBody t
- data SomeMessage where
- SomeMessage :: Message t -> SomeMessage
- data MqttHeader = Header {}
- data MessageBody t where
- MConnect :: Connect -> MessageBody CONNECT
- MConnAck :: ConnAck -> MessageBody CONNACK
- MPublish :: Publish -> MessageBody PUBLISH
- MPubAck :: SimpleMsg -> MessageBody PUBACK
- MPubRec :: SimpleMsg -> MessageBody PUBREC
- MPubRel :: SimpleMsg -> MessageBody PUBREL
- MPubComp :: SimpleMsg -> MessageBody PUBCOMP
- MSubscribe :: Subscribe -> MessageBody SUBSCRIBE
- MSubAck :: SubAck -> MessageBody SUBACK
- MUnsubscribe :: Unsubscribe -> MessageBody UNSUBSCRIBE
- MUnsubAck :: SimpleMsg -> MessageBody UNSUBACK
- MPingReq :: MessageBody PINGREQ
- MPingResp :: MessageBody PINGRESP
- MDisconnect :: MessageBody DISCONNECT
- data Connect = Connect {}
- newtype ConnAck = ConnAck {
- returnCode :: Word8
- data Publish = Publish {}
- data Subscribe = Subscribe {
- subscribeMsgID :: MsgID
- subTopics :: [(Topic, QoS)]
- data SubAck = SubAck {
- subAckMsgID :: MsgID
- granted :: [QoS]
- data Unsubscribe = Unsubscribe {
- unsubMsgID :: MsgID
- unsubTopics :: [Topic]
- newtype SimpleMsg = SimpleMsg {}
- data Will = Will {}
- data QoS
- type MsgID = Word16
- getMsgID :: MessageBody t -> Maybe MsgID
- data Topic
- fromTopic :: Topic -> MqttText
- toTopic :: MqttText -> Topic
- matches :: Topic -> Topic -> Bool
- newtype MqttText = MqttText {
- text :: Text
- data MsgType
- toMsgType :: Message t -> MsgType
- toMsgType' :: SomeMessage -> MsgType
- toSMsgType :: Message t -> SMsgType t
- type SMsgType z = Sing z
- data family Sing a
Messages
data Message t
A MQTT message, indexed by the type of the message (MsgType).
Constructors
| Message | |
Fields
| |
data SomeMessage where
Any message, hiding the index.
Constructors
| SomeMessage :: Message t -> SomeMessage |
Message bodies
data MessageBody t where
The body of a MQTT message, indexed by the type of the message (MsgType).
Constructors
| MConnect :: Connect -> MessageBody CONNECT | |
| MConnAck :: ConnAck -> MessageBody CONNACK | |
| MPublish :: Publish -> MessageBody PUBLISH | |
| MPubAck :: SimpleMsg -> MessageBody PUBACK | |
| MPubRec :: SimpleMsg -> MessageBody PUBREC | |
| MPubRel :: SimpleMsg -> MessageBody PUBREL | |
| MPubComp :: SimpleMsg -> MessageBody PUBCOMP | |
| MSubscribe :: Subscribe -> MessageBody SUBSCRIBE | |
| MSubAck :: SubAck -> MessageBody SUBACK | |
| MUnsubscribe :: Unsubscribe -> MessageBody UNSUBSCRIBE | |
| MUnsubAck :: SimpleMsg -> MessageBody UNSUBACK | |
| MPingReq :: MessageBody PINGREQ | |
| MPingResp :: MessageBody PINGRESP | |
| MDisconnect :: MessageBody DISCONNECT |
data Connect
The fields of a CONNECT message.
Constructors
| Connect | |
Fields
| |
newtype ConnAck
The response to a CONNECT. Anything other than 0 means the broker refused the connection (details).
Constructors
| ConnAck | |
Fields
| |
data Unsubscribe
The fields of a UNSUBSCRIBE message.
Constructors
| Unsubscribe | |
Fields
| |
Instances
Miscellaneous
data Will
A Will message is published by the broker if a client disconnects without sending a DISCONNECT.
data QoS
The different levels of QoS
getMsgID :: MessageBody t -> Maybe MsgID
Get the message ID of any message, if it exists.
data Topic
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.
newtype MqttText
MQTT uses length-prefixed UTF-8 as text encoding.
Message types
data MsgType
The various types of messages.
Constructors
| CONNECT | |
| CONNACK | |
| PUBLISH | |
| PUBACK | |
| PUBREC | |
| PUBREL | |
| PUBCOMP | |
| SUBSCRIBE | |
| SUBACK | |
| UNSUBSCRIBE | |
| UNSUBACK | |
| PINGREQ | |
| PINGRESP | |
| DISCONNECT |
Instances
toMsgType' :: SomeMessage -> MsgType
Determine the MsgType of a SomeMessage.
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
data family Sing a
Instances