aboutsummaryrefslogtreecommitdiff
path: root/clientmods
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 /clientmods
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 'clientmods')
-rw-r--r--clientmods/preview/init.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua
index 150db1816..bf5fb3db8 100644
--- a/clientmods/preview/init.lua
+++ b/clientmods/preview/init.lua
@@ -1,5 +1,6 @@
local modname = core.get_current_modname() or "??"
local modstorage = core.get_mod_storage()
+local mod_channel
dofile("preview:example.lua")
-- This is an example function to ensure it's working properly, should be removed before merge
@@ -14,6 +15,21 @@ core.register_on_connect(function()
print("Server ip: " .. server_info.ip)
print("Server address: " .. server_info.address)
print("Server port: " .. server_info.port)
+
+ mod_channel = core.mod_channel_join("experimental_preview")
+end)
+
+core.register_on_modchannel_message(function(channel, sender, message)
+ print("[PREVIEW][modchannels] Received message `" .. message .. "` on channel `"
+ .. channel .. "` from sender `" .. sender .. "`")
+ core.after(1, function()
+ mod_channel:send_all("CSM preview received " .. message)
+ end)
+end)
+
+core.register_on_modchannel_signal(function(channel, signal)
+ print("[PREVIEW][modchannels] Received signal id `" .. signal .. "` on channel `"
+ .. channel)
end)
core.register_on_placenode(function(pointed_thing, node)
@@ -100,6 +116,12 @@ core.after(2, function()
preview_minimap()
end)
+core.after(4, function()
+ if mod_channel:is_writeable() then
+ mod_channel:send_all("preview talk to experimental")
+ end
+end)
+
core.after(5, function()
if core.ui.minimap then
core.ui.minimap:show()