change "get" to "is"
This commit is contained in:
parent
86053fa86d
commit
1f049c2fd0
@ -95,7 +95,7 @@ socket:is_connected() --> bool
|
|||||||
socket:get_address() --> str, int
|
socket:get_address() --> str, int
|
||||||
|
|
||||||
-- Возвращает состояние NoDelay
|
-- Возвращает состояние NoDelay
|
||||||
socket:get_nodelay() --> bool
|
socket:is_nodelay() --> bool
|
||||||
|
|
||||||
-- Устанавливает состояние NoDelay
|
-- Устанавливает состояние NoDelay
|
||||||
socket:set_nodelay(state: bool)
|
socket:set_nodelay(state: bool)
|
||||||
|
|||||||
@ -45,7 +45,7 @@ local Socket = {__index={
|
|||||||
is_connected=function(self) return network.__is_connected(self.id) end,
|
is_connected=function(self) return network.__is_connected(self.id) end,
|
||||||
get_address=function(self) return network.__get_address(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,
|
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={
|
local WriteableSocket = {__index={
|
||||||
|
|||||||
@ -413,11 +413,11 @@ static int l_set_nodelay(lua::State* L, network::Network& network) {
|
|||||||
return 0;
|
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);
|
u64id_t id = lua::tointeger(L, 1);
|
||||||
if (auto connection = network.getConnection(id)) {
|
if (auto connection = network.getConnection(id)) {
|
||||||
if (connection->getTransportType() == network::TransportType::TCP) {
|
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);
|
return lua::pushboolean(L, noDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,6 +540,6 @@ const luaL_Reg networklib[] = {
|
|||||||
{"__is_serveropen", wrap<l_is_serveropen>},
|
{"__is_serveropen", wrap<l_is_serveropen>},
|
||||||
{"__get_serverport", wrap<l_get_serverport>},
|
{"__get_serverport", wrap<l_get_serverport>},
|
||||||
{"__set_nodelay", wrap<l_set_nodelay>},
|
{"__set_nodelay", wrap<l_set_nodelay>},
|
||||||
{"__get_nodelay", wrap<l_get_nodelay>},
|
{"__is_nodelay", wrap<l_is_nodelay>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -362,7 +362,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getNoDelay() const override {
|
bool isNoDelay() const override {
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
socklen_t len = sizeof(opt);
|
socklen_t len = sizeof(opt);
|
||||||
if (getsockopt(descriptor, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, &len) < 0) {
|
if (getsockopt(descriptor, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, &len) < 0) {
|
||||||
|
|||||||
@ -78,7 +78,7 @@ namespace network {
|
|||||||
virtual int recv(char* buffer, size_t length) = 0;
|
virtual int recv(char* buffer, size_t length) = 0;
|
||||||
virtual int available() = 0;
|
virtual int available() = 0;
|
||||||
virtual void setNoDelay(bool noDelay) = 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 {
|
[[nodiscard]] TransportType getTransportType() const noexcept override {
|
||||||
return TransportType::TCP;
|
return TransportType::TCP;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user