add socket:available() --> int
This commit is contained in:
@@ -123,6 +123,14 @@ static int l_recv(lua::State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_available(lua::State* L) {
|
||||
u64id_t id = lua::tointeger(L, 1);
|
||||
if (auto connection = engine->getNetwork().getConnection(id)) {
|
||||
return lua::pushinteger(L, connection->available());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_open(lua::State* L) {
|
||||
int port = lua::tointeger(L, 1);
|
||||
lua::pushvalue(L, 2);
|
||||
@@ -200,6 +208,7 @@ const luaL_Reg networklib[] = {
|
||||
{"__close", lua::wrap<l_close>},
|
||||
{"__send", lua::wrap<l_send>},
|
||||
{"__recv", lua::wrap<l_recv>},
|
||||
{"__available", lua::wrap<l_available>},
|
||||
{"__is_alive", lua::wrap<l_is_alive>},
|
||||
{"__is_connected", lua::wrap<l_is_connected>},
|
||||
{"__get_address", lua::wrap<l_get_address>},
|
||||
|
||||
Reference in New Issue
Block a user