packages feed

c-mosquitto 0.1.0.0 → 0.1.0.1

raw patch · 5 files changed

+49/−14 lines, 5 files

Files

README.md view
@@ -1,1 +1,31 @@ # c-mosquitto++[Full code](https://github.com/tolysz/c-mosquitto/blob/master/app/Main.hs)+```haskell+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"+```
app/Main.hs view
@@ -14,6 +14,7 @@     , userCert  :: String     , userKey   :: String     , server    :: String+    , serverName :: String     , port      :: Int     , keepAlive :: Int     }@@ -27,7 +28,9 @@         <*> simpleOption "key" "cert.key"             "client key"         <*> simpleOption "server" "localhost"-            "client key"+            "server"+        <*> simpleOption "name" "server-demo"+            "server's name"         <*> simpleOption "port" 8883             "server's port"         <*> simpleOption "keep-alive" 1200@@ -37,23 +40,25 @@ main = runCommand $ \MainOptions{..} args -> M.withMosquittoLibrary $ do   print M.version -  m <- M.newMosquitto True "server" (Just ())+  m <- M.newMosquitto True serverName (Just ())   M.setTls m caCert userCert userKey   M.setTlsInsecure m True    M.onMessage m print   M.onLog m $ const putStrLn-  M.onConnect m print+  M.onConnect m $ \c -> do+           print c+           M.subscribe m 0 "#"+   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+--  forkIO $ forever $ do+--    M.publish m False 0 "hello" "bla"+--    threadDelay 5000000    M.loopForever m   M.destroyMosquitto m
c-mosquitto.cabal view
@@ -1,5 +1,5 @@ name:                c-mosquitto-version:             0.1.0.0+version:             0.1.0.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.c view
@@ -78,14 +78,14 @@ }  -void inline_c_Network_Mosquitto_12_a6d84b6d438cc1f4f26a03133618129025930e03(struct mosquitto * pMosq_inline_c_0, char * hostname_inline_c_1, int port_inline_c_2, int keepAlive_inline_c_3) {-+int inline_c_Network_Mosquitto_12_98b22e49ca780ebc944cedb809c5a5097eea6100(struct mosquitto * pMosq_inline_c_0, char * hostname_inline_c_1, int port_inline_c_2, int keepAlive_inline_c_3) {+return (                mosquitto_connect( pMosq_inline_c_0                                 , hostname_inline_c_1                                 , port_inline_c_2                                 , keepAlive_inline_c_3                                 )-             ;+             ); }  
src/Network/Mosquitto.hs view
@@ -97,10 +97,10 @@                                 )        }|] -connect :: Mosquitto a -> String -> Int -> Int -> IO ()+connect :: Mosquitto a -> String -> Int -> Int -> IO Int connect mosq (C8.pack -> hostname) (fromIntegral -> port) (fromIntegral -> keepAlive) =-  withPtr mosq $ \pMosq ->-       [C.exp|void{+  fmap fromIntegral <$> withPtr mosq $ \pMosq ->+       [C.exp|int{                mosquitto_connect( $(struct mosquitto *pMosq)                                 , $bs-ptr:hostname                                 , $(int port)