add string socket:send overload
This commit is contained in:
parent
5c40cf3149
commit
36edad039c
@ -39,7 +39,7 @@ The Socket class has the following methods:
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Sends a byte array
|
-- Sends a byte array
|
||||||
socket:send(table|ByteArray)
|
socket:send(table|ByteArray|str)
|
||||||
|
|
||||||
-- Reads the received data
|
-- Reads the received data
|
||||||
socket:recv(
|
socket:recv(
|
||||||
|
|||||||
@ -39,7 +39,7 @@ network.tcp_connect(
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Отправляет массив байт
|
-- Отправляет массив байт
|
||||||
socket:send(table|ByteArray)
|
socket:send(table|ByteArray|str)
|
||||||
|
|
||||||
-- Читает полученные данные
|
-- Читает полученные данные
|
||||||
socket:recv(
|
socket:recv(
|
||||||
|
|||||||
@ -87,6 +87,9 @@ static int l_send(lua::State* L) {
|
|||||||
connection->send(
|
connection->send(
|
||||||
reinterpret_cast<char*>(bytes->data().data()), bytes->data().size()
|
reinterpret_cast<char*>(bytes->data().data()), bytes->data().size()
|
||||||
);
|
);
|
||||||
|
} else if (lua::isstring(L, 2)) {
|
||||||
|
auto string = lua::tolstring(L, 2);
|
||||||
|
connection->send(string.data(), string.length());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user