c-mosquitto 0.1.4.0 → 0.1.4.1
raw patch · 4 files changed
+23/−3 lines, 4 files
Files
- README.md +4/−0
- c-mosquitto.cabal +1/−1
- src/Network/Mosquitto.hs +13/−2
- src/Network/Mosquitto/Internal/Types.hs +5/−0
README.md view
@@ -29,3 +29,7 @@ M.destroyMosquitto m print "The end" ```++# Hacking++Documentation for used C library can be found at <https://mosquitto.org/api/files/mosquitto-h.html>.
c-mosquitto.cabal view
@@ -1,5 +1,5 @@ name: c-mosquitto-version: 0.1.4.0+version: 0.1.4.1 synopsis: Simpe mosquito MQTT binding able to work with the Amazons IoT -- description: homepage: https://github.com/tolysz/c-mosquitto#readme
src/Network/Mosquitto.hs view
@@ -101,10 +101,10 @@ ) }|] -setReconnectDelay +setReconnectDelay :: Mosquitto a -- ^ mosquitto instance -> Bool -- ^ exponential backoff- -> Int -- ^ initial backoff + -> Int -- ^ initial backoff -> Int -- ^ maximum backoff -> IO Int setReconnectDelay mosq exponential (fromIntegral -> reconnectDelay) (fromIntegral -> reconnectDelayMax) =@@ -183,6 +183,17 @@ mosquitto_message_callback_set ( $(struct mosquitto *pMosq) , $(void (*on_message)(struct mosquitto *, void *, const struct mosquitto_message *))+ );+ }|]++onPublish :: Mosquitto a -> OnPublish -> IO ()+onPublish mosq onPublish = do+ on_publish <- mkCOnPublish $ \_ _ mid -> onPublish (fromIntegral mid)+ withPtr mosq $ \pMosq ->+ [C.block|void{+ mosquitto_publish_callback_set+ ( $(struct mosquitto *pMosq)+ , $(void (*on_publish)(struct mosquitto *,void *, int)) ); }|]
src/Network/Mosquitto/Internal/Types.hs view
@@ -69,3 +69,8 @@ type COnSubscribe = Ptr C'Mosquitto -> Ptr () -> CInt -> CInt -> Ptr CInt -> IO () foreign import ccall "wrapper" mkCOnSubscribe :: COnSubscribe -> IO (FunPtr COnSubscribe)++type OnPublish = Int -> IO ()+type COnPublish = Ptr C'Mosquitto -> Ptr () -> CInt -> IO ()+foreign import ccall "wrapper"+ mkCOnPublish :: COnPublish -> IO (FunPtr COnPublish)