Added informative return value to vl_client.send_message
This commit is contained in:
parent
786dd12dc6
commit
a00df30676
4
api.lua
4
api.lua
|
@ -16,7 +16,7 @@ vl_client = {
|
|||
-- data: table to be sent to server, must be json serialisable
|
||||
local function send_data(data)
|
||||
-- TODO: Should channel ever be nil?
|
||||
if not channel then return end
|
||||
if not vl_client.is_active then return end
|
||||
|
||||
local string_data = minetest.write_json(data)
|
||||
--minetest.debug("Sending data to server:", string_data)
|
||||
|
@ -27,7 +27,7 @@ end
|
|||
-- opname: the name of the category of this message
|
||||
-- message: any json-serialisable object (not necessarily table)
|
||||
function vl_client.send_message(opname, message)
|
||||
send_data({opname, message})
|
||||
return send_data({opname, message})
|
||||
end
|
||||
|
||||
-- ON MESSAGE RECEIVED
|
||||
|
|
5
ping.lua
5
ping.lua
|
@ -4,7 +4,10 @@ minetest.register_chatcommand("ping", {
|
|||
params = "<message>",
|
||||
description = "pings the server from the client",
|
||||
func = function(param)
|
||||
vl_client.send_message("ping", {type="request", content=param})
|
||||
local send_status = vl_client.send_message("ping", {type="request", content=param})
|
||||
if not send_status then
|
||||
return false, "Client: unable to send ping"
|
||||
end
|
||||
return true, "Client: pinged server: " .. param
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue