Skip to content
Simple Amazon IoT compatible client
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
src Add support for mosquitto_diconnect Dec 5, 2018
test
.gitignore
LICENSE
README.md Note for future contributors Feb 16, 2018
Setup.hs
c-mosquitto.cabal
stack.yaml

README.md

c-mosquitto

Full code

main :: IO ()
main = runCommand $ \MainOptions{..} args -> M.withMosquittoLibrary $ do
  print M.version

  m <- M.newMosquitto True "server" (Just ())
  M.setTls m caCert userCert userKey
  M.setTlsInsecure m True

  -- callbacks
  M.onMessage m print
  M.onLog m $ const putStrLn
  M.onConnect m print
  M.onDisconnect m print
  M.onSubscribe m $ curry print

  M.connect m server port keepAlive

  M.subscribe m 0 "rcv/#"

  forkIO $ forever $ do
    M.publish m False 0 "hello" "bla"
    threadDelay 5000000

  M.loopForever m
  M.destroyMosquitto m
  print "The end"

Hacking

Documentation for used C library can be found at https://mosquitto.org/api/files/mosquitto-h.html.

You can’t perform that action at this time.