• Caleb Mingle's avatar
    mqtt: fix connfail callback · e547c2a0
    Caleb Mingle authored
    I've not been able to get the mqtt `connfail` callback to work.
    
    I'm consistently receiving `method not supported` errors:
    ```
    application.lua:53: method not supported
    stack traceback:
            [C]: in function 'on'
            application.lua:53: in main chunk
            [C]: in function 'dofile'
            init.lua:18: in function <init.lua:6>
    ```
    
    Example code:
    ```
    function on_connection_failed(client, reason)
        print("mqtt connection failed: " .. reason)
    end
    
    m:on("connfail", on_connection_failed)
    ```
    
    I believed this to be caused by the incorrect length comparison for `connfail`
    that is updated here.
    
    Once I changed that, the error went away, however the callback was never called.
    
    I believe the callback was never called because of an incorrect assignment.
    
    However, I saw this somewhat confusing description in the docs so this
    assignment may be expected?
    > The second (failure) callback aliases with the "connfail" callback available through :on(). (The "offline" callback is only called after an already established connection becomes closed. If the connect() call fails to establish a connection, the callback passed to :connect() is called and nothing else.)
    e547c2a0
mqtt.c 56.5 KB