Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Sep 11, 2024
1 parent 63d76ad commit af61845
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
12 changes: 9 additions & 3 deletions docs/game_data/spel2.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions docs/src/includes/_globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2459,8 +2459,9 @@ The callback signature is nil on_data(string response, string error)
#### [UdpServer](#UdpServer) udp_listen(string host, int port, function cb)

Start an UDP server on specified address and run callback when data arrives. Return a string from the callback to reply. Requires unsafe mode.
The server will be closed once the handle is released.
Start an UDP server on specified address and run callback when data arrives. Set port to 0 to use a random ephemeral port. Return a string from the callback to reply.
The server will be closed lazily by garbage collection once the handle is released, or immediately by calling close(). Requires unsafe mode.
<br/>The callback signature is optional<string> on_message(string msg, string src)

### udp_send

Expand Down
5 changes: 5 additions & 0 deletions docs/src/includes/_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,11 @@ tuple&lt;[Vec2](#Vec2), [Vec2](#Vec2), [Vec2](#Vec2)&gt; | [split()](https://git

Type | Name | Description
---- | ---- | -----------
nil | [close()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=close) | Closes the server.
bool | [open()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=open) | Returns true if the port was opened successfully and the server hasn't been closed yet.
string | [error()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=error) | Returns a string explaining the last error, at least if open() returned false.
string | [host](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=host) |
int | [port](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=port) |

### Vec2

Expand Down
1 change: 1 addition & 0 deletions src/game_api/script/usertypes/socket_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void register_usertypes(sol::state& lua)
/// Start an UDP server on specified address and run callback when data arrives. Set port to 0 to use a random ephemeral port. Return a string from the callback to reply.
/// The server will be closed lazily by garbage collection once the handle is released, or immediately by calling close(). Requires unsafe mode.
/// <br/>The callback signature is optional<string> on_message(string msg, string src)
// lua["udp_listen"] = [](std::string host, in_port_t port, sol::function cb) -> UdpServer*
lua["udp_listen"] = [](std::string host, in_port_t port, sol::function cb)
{
return std::unique_ptr<UdpServer>{new UdpServer(std::move(host), std::move(port), make_safe_cb<UdpServer::SocketCb>(std::move(cb)))};
Expand Down

0 comments on commit af61845

Please sign in to comment.