remove protection around user callbacks

If a user provides handlers, it's their responsibility that they are
correct.  Use a lua_call instead of a lua_pcall so that errors in user
provided handlers are propagated to the user that provided the handler.

Without this, any errors in user code are simply swallowed with no
indication that they even happened.  This is akin to the lua interpreter
simply ignoring errors and continuing on as if nothing had happened.

Example code:

    mqtt:set_callback(mosq.ON_MESSAGE, function(mid, topic, payload, qos, retain)
    print(string.format("Received mid: %d on topic: %s", mid, topic))
    error("Simulate a syntax or other error inside your callback")
    print(".... and, exited happily ;)")
    end)

This sort of user code should produce an error, but instead it prints
the first line, and keeps running, printing out again for each message
received.

Signed-off-by: Karl Palsson <karlp@remake.is>
init libmosquitto with module loading

Instead of require user to manually call init() we call it on module
loading. We keep the init() function for backwards compatibility.

Also do some whitespace fixes (spaces before tabs etc)

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
support setting callback via metamethod

This allows us to set callbacks with the syntax:

  client.ON_CONNECT = function(...) print(...) end

This also enables support for setting the callback with a string:

  client:set_callback("ON_CONNECT", function(...) print(...) end))

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
add support for Lua 5.2

fixes #1

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
use sensible defaults for connect/connect_async

We make the args for connect() and connect_async() optional and use
same defaults as mosquitto_sub:

  host = "localhost"
  port = 1883
  keepalive = 60

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>