net-mqtt-0.2.4.1: An MQTT Protocol Implementation.

Copyright(c) Dustin Sallings 2019
LicenseBSD3
Maintainerdustin@spy.net
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Network.MQTT.Client

Contents

Description

An MQTT protocol client, based on the 3.1.1 specification: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html

Synopsis

Configuring the client.

data MQTTConfig Source #

Configuration for setting up an MQTT client.

Constructors

MQTTConfig 

Fields

data MQTTClient Source #

The MQTT client. A client may be built using either runClient or runClientTLS. For example:

  mc <- runClient mqttConfig{}
  publish mc "some/topic" "some message" False

data QoS Source #

QoS values for publishing and subscribing.

Constructors

QoS0 
QoS1 
QoS2 
Instances
Bounded QoS Source # 
Instance details

Defined in Network.MQTT.Types

Methods

minBound :: QoS #

maxBound :: QoS #

Enum QoS Source # 
Instance details

Defined in Network.MQTT.Types

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 # 
Instance details

Defined in Network.MQTT.Types

Methods

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

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

Show QoS Source # 
Instance details

Defined in Network.MQTT.Types

Methods

showsPrec :: Int -> QoS -> ShowS #

show :: QoS -> String #

showList :: [QoS] -> ShowS #

type Topic = Text Source #

An MQTT topic.

mqttConfig :: MQTTConfig Source #

A default MQTTConfig. A _connID should be provided by the client in the returned config, but the defaults should work for testing.

mkLWT :: Topic -> ByteString -> Bool -> LastWill Source #

A convenience method for creating a LastWill.

data LastWill Source #

An MQTT Will message.

Instances
Eq LastWill Source # 
Instance details

Defined in Network.MQTT.Types

Show LastWill Source # 
Instance details

Defined in Network.MQTT.Types

Running and waiting for the client.

runClient :: MQTTConfig -> IO MQTTClient Source #

Set up and run a client from the given config.

runClientTLS :: MQTTConfig -> IO MQTTClient Source #

Set up and run a client connected via TLS.

waitForClient :: MQTTClient -> IO (Either SomeException ()) Source #

Wait for a client to terminate its connection.

connectURI :: MQTTConfig -> URI -> IO MQTTClient Source #

Connect to an MQTT server by URI. Currently only mqtt and mqtts URLs are supported. The host, port, username, and password will be derived from the URI and the values supplied in the config will be ignored.

disconnect :: MQTTClient -> IO () Source #

Disconnect from the MQTT server.

General client interactions.

subscribe :: MQTTClient -> [(Filter, QoS)] -> IO [Maybe QoS] Source #

Subscribe to a list of topic filters with their respective QoSes. The accepted QoSes are returned in the same order as requested.

unsubscribe :: MQTTClient -> [Filter] -> IO () Source #

Unsubscribe from a list of topic filters.

publish Source #

Arguments

:: MQTTClient 
-> Topic

Topic

-> ByteString

Message body

-> Bool

Retain flag

-> IO () 

Publish a message (QoS 0).

publishq Source #

Arguments

:: MQTTClient 
-> Topic

Topic

-> ByteString

Message body

-> Bool

Retain flag

-> QoS

QoS

-> IO () 

Publish a message with the specified QoS.