aboutsummaryrefslogtreecommitdiffstats
path: root/alv/copilot
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2023-11-11 15:52:08 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commit31603cdcf26fd6a5ba7ee600b601f50dd6c17517 (patch)
tree641196fe3cd459b8e10e263c249940b17bc419ea /alv/copilot
parentsmall fixes (diff)
downloadalive-31603cdcf26fd6a5ba7ee600b601f50dd6c17517.tar.gz
alive-31603cdcf26fd6a5ba7ee600b601f50dd6c17517.zip
small fixes
Diffstat (limited to 'alv/copilot')
-rw-r--r--alv/copilot/udp.moon11
1 files changed, 10 insertions, 1 deletions
diff --git a/alv/copilot/udp.moon b/alv/copilot/udp.moon
index f5deb50..7babd04 100644
--- a/alv/copilot/udp.moon
+++ b/alv/copilot/udp.moon
@@ -16,6 +16,14 @@ encode_res = =>
type: tostring @type
}
+encode_opts = {
+ exception: (reason, value, state, msg) ->
+ if reason == "unsupported type"
+ return "null"
+
+ nil, msg
+}
+
class UDPServer
new: (@copilot) =>
@sock = udp!
@@ -32,7 +40,8 @@ class UDPServer
@handle msg, client
else
error: 'invalid message'
- @sock\sendto (encode res), ip, port
+ data = encode res, encode_opts
+ @sock\sendto data, ip, port
handle: (msg, client) =>
res = { id: msg.id }