Skip to content
forked from suvash/hulaaki

An MQTT 3.1.1 client library written in Elixir

License

Notifications You must be signed in to change notification settings

arunpoudel/hulaaki

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hulaaki (हुलाकी)

Build Status Coverage Status Inline docs

Hulaaki is a client library for MQTT 3.1.1 entirely written in Elixir.

Usage

Before we get started, keep in mind that you need a running MQTT server that you can connect to.

Add Hulaaki to your project dependencies in mix.exs

def deps do
  [{:hulaaki, "~> 0.0.2"} ]
end

The quickest way to get up and running with Hulaaki is to use the provided Client module. This Genserver module defines function callbacks that are intended to be overridden for required implementations. The callbacks are defined for each MQTT message that is being sent and received from the server.

Add the following sample client to your project.

defmodule SampleClient do
  use Hulaaki.Client

  def on_connect_ack(options) do
    IO.inspect options
  end

  def on_subscribed_publish(options) do
    IO.inspect options
  end

  def on_subscribe_ack(options) do
    IO.inspect options
  end

  def on_pong(options) do
    IO.inspect options
  end
end

Load the project in iex -S mix to explore the SampleClient

$ iex -S mix

> {:ok, pid} = SampleClient.start_link(%{})

> options = [client_id: "some-name", host: "localhost", port: 1883]

> SampleClient.connect(pid, options)

> SampleClient.ping(pid)

Once you get the idea, feel free to check the inline documentation and client_test.exs for more example usage and test strategy.

Documentation

Please refer to the inline documentation and tests to explore the documentation for now. This shall be improved over time.

Immediate TODOs

  • Pingpong based heartbeat in Client based on the timeout.
  • .....

Contributing

Pull requests with appropriate tests and improvements are welcome. Mosquitto is currently used by the author to test the library. Please take a look at the Makefile to run tests.

Naming

Hulaaki(pronouced as who-laa-key) is the phonetic spelling of the word हुलाकी in Nepali, which translates to Postman in English.

About

An MQTT 3.1.1 client library written in Elixir

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 99.9%
  • Makefile 0.1%