From de5722890c461d36416e4684bd5781099b2bdc46 Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Sun, 2 Jan 2022 23:50:53 -0500 Subject: [PATCH] document client side modchannels --- doc/modchannels.adoc | 65 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/doc/modchannels.adoc b/doc/modchannels.adoc index f1cbe4f..792db57 100644 --- a/doc/modchannels.adoc +++ b/doc/modchannels.adoc @@ -1,34 +1,81 @@ = Modchannels -allows ssm(server side mods) comunication to csm(client side mods) and vice versa. +allows server side mods(SSMs) comunication to client side mods(CSMs) and vice versa. -== minetest.x api +== Server Side API -=== minetest.mod_channel_join(channel_name) +=== Functions + +==== minetest.mod_channel_join(channel_name) * `channel_name`: string, modchannel name -* returns ref for use with <> +* returns ref for use with <> * creates channel if not existing and joins the server on that channel * listen for messages on this channel with `minetest.register_on_modchannel_message` -=== minetest.register_on_modchannel_message(function(channel_name, sender, message)) +==== minetest.register_on_modchannel_message(function(channel_name, sender, message)) * `channel_name`: string, modchannel name (already joined) * `sender`: string, empty if from a ssm, player name if from a client * `message`: string, message -== methods +=== Methods -=== leave() +==== leave() * server leaves the channel, no more messages from this channel on `minetest.register_on_modchannel_message` * set the ref to nil afterwords to free resources -=== is_writeable() +==== is_writeable() * returns boolean, true if the channel is writeable -=== send_all(message) +==== send_all(message) + +* `message`: string, limited to 65535 characters +* sends to all ssm and csm on the channel +* message will drop if channel is not writable or invalid + +== Client Side API + +=== Functions + +==== minetest.mod_channel_join(channel_name) + +* `channel_name`: string, modchannel name +* returns ref for use with <> +* creates channel if not existing and joins the server on that channel +* listen for messages on this channel with `minetest.register_on_modchannel_message` + +==== minetest.register_on_modchannel_message(function(channel_name, sender, message)) + +* `channel_name`: string, modchannel name (already joined and recieved acknowledgement) +* `sender`: string, empty if from a ssm, player name if from a client +* `message`: string, message + +==== minetest.register_on_modchannel_signal(function(channel_name, signal)) +* `channel_name`: string, channel name that the signal has come in on +* `signal`: integer, 0 - 5 +[start=0] +. join_ok +. join_failed +. leave_ok +. leave_failed +. event_on_not_joined_channel +. state_changed + +=== Methods + +==== leave() + +* server leaves the channel, no more messages from this channel on `minetest.register_on_modchannel_message` +* set the ref to nil afterwords to free resources + +==== is_writeable() + +* returns boolean, true if the channel is writeable + +==== send_all(message) * `message`: string, limited to 65535 characters * sends to all ssm and csm on the channel