Beispiel #1
0
LUALIB_API int lua_onConnect(lua_State *L)
{
    Instance *i = (Instance *)luaL_checkudata(L, 1, "tig_server_instance");

    luv_register_event(L, 1, "connect", 2);
    return 0;
}
Beispiel #2
0
int luv_set_handler(lua_State* L) {
    const char* name;
    luv_checkudata(L, 1, "handle");
    name = luaL_checkstring(L, 2);
    luaL_checktype(L, 3, LUA_TFUNCTION);

    luv_register_event(L, 1, name, 3);

    return 0;
}
Beispiel #3
0
int luv_set_handler(lua_State* L) {
  int before = lua_gettop(L);
  luv_checkudata(L, 1, "handle");
  const char* name = luaL_checkstring(L, 2);
  luaL_checktype(L, 3, LUA_TFUNCTION);

  luv_register_event(L, 1, name, 3);

  assert(lua_gettop(L) == before);
  return 0;
}
Beispiel #4
0
static int lua_client_on_error(lua_State *L)
{
  lua_redis_client_t *lua_redis_client = (lua_redis_client_t *)
                                    luaL_checkudata(L, 1, LUA_REDIS_CLIENT_MT);

  if (lua_redis_client->redis_async_context == NULL)
  {
    return luaL_error(L, "RedisAsyncContext is null");
  }

  luv_register_event(L, 1, "error", 2);

  return 0;
}
Beispiel #5
0
int luv_timer_start(lua_State* L) {
    uv_timer_t* handle = (uv_timer_t*)luv_checkudata(L, 1, "timer");
    int64_t timeout = luaL_checklong(L, 2);
    int64_t repeat = luaL_checklong(L, 3);
    luaL_checktype(L, 4, LUA_TFUNCTION);

    luv_register_event(L, 1, "timeout", 4);

    int err = uv_timer_start(handle, luv_on_timer, timeout, repeat);
    if (err < 0) {
        return luaL_error(L, "timer_start: %s", uv_strerror(err));
    }
    luv_handle_ref(L, handle->data, 1);

    return 0;
}