Rename pings

This commit is contained in:
NullBite 2023-06-23 16:43:58 -04:00
parent b9975082d0
commit 0fa6341bf2
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A

View File

@ -76,7 +76,8 @@ do
--- Set value and run callback --- Set value and run callback
-- Sets a value in the state table, initializing it if neede, and runs -- Sets a value in the state table, initializing it if neede, and runs
-- the callback if it has been previously set -- the callback if it has been previously set. This function should
-- only be called within ping receiver functions
---@param key string key ---@param key string key
---@param value any value ---@param value any value
---@param callback? function callback function ---@param callback? function callback function
@ -145,8 +146,8 @@ sharedstate.add=sharedstate.init
---directly ---directly
---@param index integer Index of key ---@param index integer Index of key
---@param value any New value ---@param value any New value
function pings.sharedstate_transfer(index, value) function pings.sharedstate_recv(index, value)
logging.trace("pings.sharedstate_transfer", index, value) logging.trace("pings.sharedstate_recv", index, value)
set_value(resolve_key(index), value) set_value(resolve_key(index), value)
end end
@ -155,11 +156,19 @@ end
---directly ---directly
---@param key string Key ---@param key string Key
---@param value any New value ---@param value any New value
function pings.sharedstate_ktransfer(key, value) function pings.sharedstate_recv_named(key, value)
logging.trace("pings.sharedstate_ktransfer", key, value) logging.trace("pings.sharedstate_recv_named", key, value)
set_value(key, value) set_value(key, value)
end end
--- Internal; unpack a table of state into the local state store
---@param tbl table Table to unpack
function pings.sharedstate_recv_table(tbl)
for k, v in pairs(tbl) do
set_value(k, v["value"])
end
end
--- Set shared value --- Set shared value
---Sets a shared value. This sends a ping to transfer it over the network. ---Sets a shared value. This sends a ping to transfer it over the network.
---@param key string key name ---@param key string key name
@ -171,8 +180,8 @@ function sharedstate.set(key, value)
local errormsg="sharedstate: Key " .. key .. " has not been initialized." local errormsg="sharedstate: Key " .. key .. " has not been initialized."
error(errormsg) error(errormsg)
end end
pings.sharedstate_transfer(resolve_index(key), value) pings.sharedstate_recv(resolve_index(key), value)
-- pings.sharedstate_ktransfer(key, value) -- pings.sharedstate_recv_named(key, value)
end end
---Send queued entries ---Send queued entries