packages feed

net-mqtt 0.6.0.0 → 0.6.0.1

raw patch · 4 files changed

+34/−21 lines, 4 filesdep ~QuickCheckPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: QuickCheck

API changes (from Hackage documentation)

+ Network.MQTT.Client: [_connectTimeout] :: MQTTConfig -> Int
- Network.MQTT.Client: MQTTConfig :: Bool -> Maybe LastWill -> MessageCallback -> ProtocolLevel -> [Property] -> String -> Int -> String -> Maybe String -> Maybe String -> MQTTConfig
+ Network.MQTT.Client: MQTTConfig :: Bool -> Maybe LastWill -> MessageCallback -> ProtocolLevel -> [Property] -> String -> Int -> String -> Maybe String -> Maybe String -> Int -> MQTTConfig

Files

Changelog.md view
@@ -1,5 +1,11 @@ # Changelog for net-mqtt +## 0.6.0.1++Relaxed QuickCheck constraint slightly.++Added connection timeout.+ ## 0.6.0.0  Many changes went into this release.
README.md view
@@ -20,7 +20,7 @@ main :: IO main = do   let (Just uri) = parseURI "mqtt://test.mosquitto.org"-  mc <- connectURI mqttConfig{_msgCB=Just msgReceived} uri+  mc <- connectURI mqttConfig{_msgCB=SimpleCallback msgReceived} uri   print =<< subscribe mc [("tmp/topic1", subOptions), ("tmp/topic2", subOptions)] []   waitForClient mc   -- wait for the the client to disconnect 
net-mqtt.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: ae5feb10e5396e515bcfcd831e587293224b3acb60a3ce8e80e34c9eef4f9a66+-- hash: 2d689138895486415ae00cada1b378197a188735047e04bd037c0f147fdd81f5  name:           net-mqtt-version:        0.6.0.0+version:        0.6.0.1 synopsis:       An MQTT Protocol Implementation. description:    Please see the README on GitHub at <https://github.com/dustin/mqtt-hs#readme> category:       Network@@ -39,7 +39,7 @@       src   ghc-options: -Wall   build-depends:-      QuickCheck >=2.12.6.1 && <2.13+      QuickCheck >=2.12.6.1 && <2.14     , async >=2.2.1 && <2.3     , attoparsec >=0.13.2 && <0.14     , attoparsec-binary >=0.2 && <1.0@@ -66,7 +66,7 @@       app/example   ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N   build-depends:-      QuickCheck >=2.12.6.1 && <2.13+      QuickCheck >=2.12.6.1 && <2.14     , async >=2.2.1 && <2.3     , attoparsec >=0.13.2 && <0.14     , attoparsec-binary >=0.2 && <1.0@@ -94,7 +94,7 @@       app/mqtt-watch   ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N   build-depends:-      QuickCheck >=2.12.6.1 && <2.13+      QuickCheck >=2.12.6.1 && <2.14     , async >=2.2.1 && <2.3     , attoparsec >=0.13.2 && <0.14     , attoparsec-binary >=0.2 && <1.0@@ -125,7 +125,7 @@   ghc-options: -threaded -rtsopts -with-rtsopts=-N   build-depends:       HUnit-    , QuickCheck >=2.12.6.1 && <2.13+    , QuickCheck >=2.12.6.1 && <2.14     , async >=2.2.1 && <2.3     , attoparsec >=0.13.2 && <0.14     , attoparsec-binary >=0.2 && <1.0
src/Network/MQTT/Client.hs view
@@ -104,16 +104,17 @@  -- | Configuration for setting up an MQTT client. data MQTTConfig = MQTTConfig{-  _cleanSession :: Bool -- ^ False if a session should be reused.-  , _lwt        :: Maybe LastWill -- ^ LastWill message to be sent on client disconnect.-  , _msgCB      :: MessageCallback -- ^ Callback for incoming messages.-  , _protocol   :: ProtocolLevel -- ^ Protocol to use for the connection.-  , _connProps  :: [Property] -- ^ Properties to send to the broker in the CONNECT packet.-  , _hostname   :: String -- ^ Host to connect to (parsed from the URI)-  , _port       :: Int -- ^ Port number (parsed from the URI)-  , _connID     :: String -- ^ Unique connection ID (parsed from the URI)-  , _username   :: Maybe String -- ^ Optional username (parsed from the URI)-  , _password   :: Maybe String -- ^ Optional password (parsed from the URI)+  _cleanSession     :: Bool -- ^ False if a session should be reused.+  , _lwt            :: Maybe LastWill -- ^ LastWill message to be sent on client disconnect.+  , _msgCB          :: MessageCallback -- ^ Callback for incoming messages.+  , _protocol       :: ProtocolLevel -- ^ Protocol to use for the connection.+  , _connProps      :: [Property] -- ^ Properties to send to the broker in the CONNECT packet.+  , _hostname       :: String -- ^ Host to connect to (parsed from the URI)+  , _port           :: Int -- ^ Port number (parsed from the URI)+  , _connID         :: String -- ^ Unique connection ID (parsed from the URI)+  , _username       :: Maybe String -- ^ Optional username (parsed from the URI)+  , _password       :: Maybe String -- ^ Optional password (parsed from the URI)+  , _connectTimeout :: Int -- ^ Connection timeout (microseconds)   }  -- | A default 'MQTTConfig'.  A '_connID' /may/ be required depending on@@ -126,7 +127,8 @@                         _username=Nothing, _password=Nothing,                         _cleanSession=True, _lwt=Nothing,                         _msgCB=NoCallback,-                        _protocol=Protocol311, _connProps=mempty}+                        _protocol=Protocol311, _connProps=mempty,+                        _connectTimeout=180000000}  -- | Connect to an MQTT server by URI. --@@ -151,9 +153,14 @@       (Just a) = uriAuthority uri       (u,p) = up (uriUserInfo a) -  cf cfg{Network.MQTT.Client._connID=cid _protocol (uriFragment uri),-         _hostname=uriRegName a, _port=port (uriPort a) (uriScheme uri),-         Network.MQTT.Client._username=u, Network.MQTT.Client._password=p}+  v <- timeout _connectTimeout $+    cf cfg{Network.MQTT.Client._connID=cid _protocol (uriFragment uri),+           _hostname=uriRegName a, _port=port (uriPort a) (uriScheme uri),+           Network.MQTT.Client._username=u, Network.MQTT.Client._password=p}++  case v of+    Nothing -> mqttFail $ "connection to " <> show uri <> " timed out"+    Just x  -> pure x    where     port "" "mqtt:"  = 1883