From 6f1c90720402415b62fb4d5e809ec7dbc1cd7f96 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Tue, 26 Sep 2017 00:11:20 +0200 Subject: 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 --- games/minimal/mods/experimental/init.lua | 2 ++ games/minimal/mods/experimental/modchannels.lua | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 games/minimal/mods/experimental/modchannels.lua (limited to 'games/minimal') 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!") -- cgit v1.2.3