Copyright | Lukas Braun 2014-2016 |
---|---|
License | GPL-3 |
Maintainer | koomi+mqtt@hackerspace-bamberg.de |
Safe Haskell | None |
Language | Haskell2010 |
Parsers for MQTT messages.
- type MessageParser a = StateT Word32 Parser a
- message :: Parser SomeMessage
- mqttHeader :: Parser (MsgType, MqttHeader)
- parseRemaining :: Parser Word32
- mqttBody :: MqttHeader -> SMsgType t -> Word32 -> Parser (MessageBody t)
- connect :: MessageParser (MessageBody CONNECT)
- connAck :: MessageParser (MessageBody CONNACK)
- publish :: MqttHeader -> MessageParser (MessageBody PUBLISH)
- subscribe :: MessageParser (MessageBody SUBSCRIBE)
- subAck :: MessageParser (MessageBody SUBACK)
- unsubscribe :: MessageParser (MessageBody UNSUBSCRIBE)
- getTopic :: MessageParser Topic
- mqttText :: MessageParser MqttText
- parseMsgID :: MessageParser Word16
- anyWord16BE :: (Num a, Bits a) => MessageParser a
- anyWord8' :: MessageParser Word8
- ctxt :: String -> Parser a -> Parser a
- ctxt' :: String -> MessageParser a -> MessageParser a
- take' :: Word32 -> MessageParser ByteString
- parseLength :: Word32 -> MessageParser ()
- toQoS :: (Num a, Eq a, Show a, Monad m) => a -> m QoS
Documentation
type MessageParser a = StateT Word32 Parser a Source #
Type of a parser that also keeps track of the remaining length.
message :: Parser SomeMessage Source #
Parse any MQTT message.
Fixed Header
mqttHeader :: Parser (MsgType, MqttHeader) Source #
Parser for the fixed header part of a MQTT message.
parseRemaining :: Parser Word32 Source #
Parse the 'remaining length' field that indicates how long the rest of the message is.
Message Body
mqttBody :: MqttHeader -> SMsgType t -> Word32 -> Parser (MessageBody t) Source #
«mqttBody header msgtype remaining
» parses a Message
of type
msgtype
that is remaining
bytes long.
publish :: MqttHeader -> MessageParser (MessageBody PUBLISH) Source #
Utility functions
getTopic :: MessageParser Topic Source #
Parse a topic name.
mqttText :: MessageParser MqttText Source #
Parse a length-prefixed UTF-8 string.
parseMsgID :: MessageParser Word16 Source #
Synonym for anyWord16BE
.
anyWord16BE :: (Num a, Bits a) => MessageParser a Source #
Parse a big-endian 16bit integer.
anyWord8' :: MessageParser Word8 Source #
A lifted version of attoparsec's anyWord8
that also subtracts 1 from
the remaining length.
ctxt' :: String -> MessageParser a -> MessageParser a Source #
take' :: Word32 -> MessageParser ByteString Source #
A lifted version of attoparsec's take
that also subtracts the
length.
parseLength :: Word32 -> MessageParser () Source #
Subtract n
from the remaining length or fail
if there is not
enough input left.