mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 07:24:53 +09:00
Send raw payloads over UDP and emit them as udp events
Review feedback from Cooldude2606: UDP is most useful for arbitrary blobs, so send_udp now takes any string and the packet is just "channel?payload". Plugins get it as a udp-<channel> event with the payload as a Buffer, or through handleUdp which logs handler errors like handle does for ipc events. The host socket is now opened when the RCON client is started and closed where the RCON client is ended, matching how the RCON client is handled, instead of being bound in start() and closed by _resetState. The integration round trip moved to the FactorioServer tests, where it sends a packet each way through a real server without the module. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b0238b64b
commit
7a64706c82
8 files changed
+222
-134
No files matched your search
@@ -253,17 +253,16 @@ Parameters:
|
||||
|
||||
#### clusterio_api.send_udp(channel, data)
|
||||
|
||||
Send JSON data to Clusterio over the given channel using UDP instead of stdout.
|
||||
Clusterio plugins receive it the same way as data sent with `send_json`.
|
||||
Send data to Clusterio over the given channel using UDP instead of stdout.
|
||||
Clusterio plugins receive it as `udp-channel_name` events, see the [Communicating over UDP section](writing-plugins.md#communicating-over-udp) in the Writing Plugins document.
|
||||
Requires `factorio.enable_lua_udp` to be enabled on the instance and Factorio 2.0.59 or later, otherwise the data is silently dropped.
|
||||
The port to send to is passed to the module with a script command on startup, so `factorio.enable_script_commands` must be enabled as well.
|
||||
See the [Communicating over UDP section](writing-plugins.md#communicating-over-udp) in the Writing Plugins document for more information.
|
||||
|
||||
**Note**: Delivery is not guaranteed and payloads must be less than 64 kB.
|
||||
**Note**: Delivery is not guaranteed and payloads should be kept well below 32 kB.
|
||||
|
||||
Parameters:
|
||||
- `channel`: string identifying which channel to send it on.
|
||||
- `data`: table that can be converted to JSON with game.table_to_json
|
||||
- `data`: string with the payload to send, any bytes are allowed.
|
||||
|
||||
|
||||
### serialize library
|
||||
|
||||
Reference in new issue
Block a user