aboutsummaryrefslogtreecommitdiff
path: root/games/minimal
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-09-26 00:11:20 +0200
committerGitHub <noreply@github.com>2017-09-26 00:11:20 +0200
commit6f1c90720402415b62fb4d5e809ec7dbc1cd7f96 (patch)
tree6f94c2bbc2d343be50945a0074bc16da282a4bc1 /games/minimal
parent6df312a608912b3cb21d04532151e29e8b0c7301 (diff)
downloadminetest-6f1c90720402415b62fb4d5e809ec7dbc1cd7f96.tar.gz
minetest-6f1c90720402415b62fb4d5e809ec7dbc1cd7f96.tar.bz2
minetest-6f1c90720402415b62fb4d5e809ec7dbc1cd7f96.zip
Implement mod communication channels (#6351)
Implement network communication for channels * Implement ModChannel manager server side to route incoming messages from clients to other clients * Add signal handler switch on client & ModChannelMgr on client to handle channels * Add Lua API bindings + client packet sending + unittests * Implement server message sending * Add callback from received message handler to Lua API using registration method
Diffstat (limited to 'games/minimal')
-rw-r--r--games/minimal/mods/experimental/init.lua2
-rw-r--r--games/minimal/mods/experimental/modchannels.lua16
2 files changed, 18 insertions, 0 deletions
diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua
index afa136777..657148dce 100644
--- a/games/minimal/mods/experimental/init.lua
+++ b/games/minimal/mods/experimental/init.lua
@@ -2,6 +2,8 @@
-- Experimental things
--
+dofile(minetest.get_modpath("experimental").."/modchannels.lua")
+
-- For testing random stuff
experimental = {}
diff --git a/games/minimal/mods/experimental/modchannels.lua b/games/minimal/mods/experimental/modchannels.lua
new file mode 100644
index 000000000..8fce6cfc4
--- /dev/null
+++ b/games/minimal/mods/experimental/modchannels.lua
@@ -0,0 +1,16 @@
+--
+-- Mod channels experimental handlers
+--
+local mod_channel = core.mod_channel_join("experimental_preview")
+
+core.register_on_modchannel_message(function(channel, sender, message)
+ print("[minimal][modchannels] Server received message `" .. message
+ .. "` on channel `" .. channel .. "` from sender `" .. sender .. "`")
+
+ if mod_channel:is_writeable() then
+ mod_channel:send_all("experimental answers to preview")
+ mod_channel:leave()
+ end
+end)
+
+print("[minimal][modchannels] Code loaded!")