| Copyright | Lukas Braun 2014 |
|---|---|
| License | GPL-3 |
| Maintainer | koomi+mqtt@hackerspace-bamberg.de |
| Safe Haskell | None |
| Language | Haskell2010 |
Network.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
A MQTT message, indexed by the type of the message (MsgType).
Constructors
| Message | |
Fields
| |
data SomeMessage where Source
Any message, hiding the index.
Constructors
| SomeMessage :: Message t -> SomeMessage |
Message bodies
data MessageBody t where Source
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 |
The fields of a CONNECT message.
Constructors
| Connect | |
Fields
| |
The response to a CONNECT. Anything other than 0 means the broker refused the connection (details).
Constructors
| ConnAck | |
Fields
| |
The fields of a PUBLISH message.
Constructors
| Publish | |
The fields of a SUBSCRIBE message.
Constructors
| Subscribe | |
The fields of a SUBACK message.
Constructors
| SubAck | |
data Unsubscribe Source
The fields of a UNSUBSCRIBE message.
Constructors
| Unsubscribe | |
Fields
| |
Instances
Any message body that consists only of a MsgID.
Miscellaneous
A Will message is published by the broker if a client disconnects without sending a DISCONNECT.
The different levels of QoS
getMsgID :: MessageBody t -> Maybe MsgID Source
Get the message ID of any message, if it exists.
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.
MQTT uses length-prefixed UTF-8 as text encoding.
Message types
The various types of messages.
Constructors
| CONNECT | |
| CONNACK | |
| PUBLISH | |
| PUBACK | |
| PUBREC | |
| PUBREL | |
| PUBCOMP | |
| SUBSCRIBE | |
| SUBACK | |
| UNSUBSCRIBE | |
| UNSUBACK | |
| PINGREQ | |
| PINGRESP | |
| DISCONNECT |
Instances
toMsgType' :: SomeMessage -> MsgType Source
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.
data family Sing a
Instances