change "get" to "is"

This commit is contained in:
Xertis 2025-10-01 01:05:30 +03:00
parent 86053fa86d
commit 1f049c2fd0
5 changed files with 7 additions and 7 deletions

View File

@ -95,7 +95,7 @@ socket:is_connected() --> bool
socket:get_address() --> str, int
-- Возвращает состояние NoDelay
socket:get_nodelay() --> bool
socket:is_nodelay() --> bool
-- Устанавливает состояние NoDelay
socket:set_nodelay(state: bool)

View File

@ -45,7 +45,7 @@ local Socket = {__index={
is_connected=function(self) return network.__is_connected(self.id) end,
get_address=function(self) return network.__get_address(self.id) end,
set_nodelay=function(self, nodelay) return network.__set_nodelay(self.id, nodelay or false) end,
get_nodelay=function(self) return network.__get_nodelay(self.id) end,
is_nodelay=function(self) return network.__is_nodelay(self.id) end,
}}
local WriteableSocket = {__index={

View File

@ -413,11 +413,11 @@ static int l_set_nodelay(lua::State* L, network::Network& network) {
return 0;
}
static int l_get_nodelay(lua::State* L, network::Network& network) {
static int l_is_nodelay(lua::State* L, network::Network& network) {
u64id_t id = lua::tointeger(L, 1);
if (auto connection = network.getConnection(id)) {
if (connection->getTransportType() == network::TransportType::TCP) {
bool noDelay = dynamic_cast<network::TcpConnection*>(connection)->getNoDelay();
bool noDelay = dynamic_cast<network::TcpConnection*>(connection)->isNoDelay();
return lua::pushboolean(L, noDelay);
}
}
@ -540,6 +540,6 @@ const luaL_Reg networklib[] = {
{"__is_serveropen", wrap<l_is_serveropen>},
{"__get_serverport", wrap<l_get_serverport>},
{"__set_nodelay", wrap<l_set_nodelay>},
{"__get_nodelay", wrap<l_get_nodelay>},
{"__is_nodelay", wrap<l_is_nodelay>},
{NULL, NULL}
};

View File

@ -362,7 +362,7 @@ public:
}
}
bool getNoDelay() const override {
bool isNoDelay() const override {
int opt = 0;
socklen_t len = sizeof(opt);
if (getsockopt(descriptor, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, &len) < 0) {

View File

@ -78,7 +78,7 @@ namespace network {
virtual int recv(char* buffer, size_t length) = 0;
virtual int available() = 0;
virtual void setNoDelay(bool noDelay) = 0;
[[nodiscard]] virtual bool getNoDelay() const = 0;
[[nodiscard]] virtual bool isNoDelay() const = 0;
[[nodiscard]] TransportType getTransportType() const noexcept override {
return TransportType::TCP;