Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lua-mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,17 @@ static int ctx_reconnect(lua_State *L)
return mosq__pstatus(L, rc);
}

static int ctx_reconnect_delay_set(lua_State *L)
{
ctx_t *ctx = ctx_check(L, 1);
int reconnect_delay = luaL_optinteger(L, 2, 1);
int reconnect_delay_max = luaL_optinteger(L, 3, 30);
bool reconnect_exponential_backoff = (lua_isboolean(L, 4) ? lua_toboolean(L, 4) : true);

int rc = mosquitto_reconnect_delay_set(ctx->mosq, reconnect_delay, reconnect_delay_max, reconnect_exponential_backoff);
return mosq__pstatus(L, rc);
}

static int ctx_disconnect(lua_State *L)
{
ctx_t *ctx = ctx_check(L, 1);
Expand Down Expand Up @@ -799,6 +810,7 @@ static const struct luaL_Reg ctx_M[] = {
{"connect", ctx_connect},
{"connect_async", ctx_connect_async},
{"reconnect", ctx_reconnect},
{"reconnect_delay_set", ctx_reconnect_delay_set},
{"disconnect", ctx_disconnect},
{"publish", ctx_publish},
{"subscribe", ctx_subscribe},
Expand Down