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.Parser

Contents

Description

Parsers for MQTT messages.

Synopsis

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.

Utility functions

getTopic :: MessageParser Topic Source #

Parse a topic name.

mqttText :: MessageParser MqttText Source #

Parse a length-prefixed UTF-8 string.

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.

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.

toQoS :: (Num a, Eq a, Show a, Monad m) => a -> m QoS Source #

Convert a number to a QoS. fail if the number can't be converted.