refactor vc coroutines error-handling & update socket:is_alive(), socket:send(...)

This commit is contained in:
MihailRis
2025-01-15 05:27:10 +03:00
parent 00ce65ef66
commit b8944f86c6
2 changed files with 10 additions and 13 deletions
+5 -2
View File
@@ -89,7 +89,8 @@ static int l_closeserver(lua::State* L) {
static int l_send(lua::State* L) {
u64id_t id = lua::tointeger(L, 1);
auto connection = engine->getNetwork().getConnection(id);
if (connection == nullptr) {
if (connection == nullptr ||
connection->getState() == network::ConnectionState::CLOSED) {
return 0;
}
if (lua::istable(L, 2)) {
@@ -167,7 +168,9 @@ static int l_is_alive(lua::State* L) {
u64id_t id = lua::tointeger(L, 1);
if (auto connection = engine->getNetwork().getConnection(id)) {
return lua::pushboolean(
L, connection->getState() != network::ConnectionState::CLOSED
L,
connection->getState() != network::ConnectionState::CLOSED ||
connection->available() > 0
);
}
return lua::pushboolean(L, false);