Rename pings
This commit is contained in:
parent
b9975082d0
commit
0fa6341bf2
@ -76,7 +76,8 @@ do
|
||||
|
||||
--- Set value and run callback
|
||||
-- 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 value any value
|
||||
---@param callback? function callback function
|
||||
@ -145,8 +146,8 @@ sharedstate.add=sharedstate.init
|
||||
---directly
|
||||
---@param index integer Index of key
|
||||
---@param value any New value
|
||||
function pings.sharedstate_transfer(index, value)
|
||||
logging.trace("pings.sharedstate_transfer", index, value)
|
||||
function pings.sharedstate_recv(index, value)
|
||||
logging.trace("pings.sharedstate_recv", index, value)
|
||||
set_value(resolve_key(index), value)
|
||||
end
|
||||
|
||||
@ -155,11 +156,19 @@ end
|
||||
---directly
|
||||
---@param key string Key
|
||||
---@param value any New value
|
||||
function pings.sharedstate_ktransfer(key, value)
|
||||
logging.trace("pings.sharedstate_ktransfer", key, value)
|
||||
function pings.sharedstate_recv_named(key, value)
|
||||
logging.trace("pings.sharedstate_recv_named", key, value)
|
||||
set_value(key, value)
|
||||
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
|
||||
---Sets a shared value. This sends a ping to transfer it over the network.
|
||||
---@param key string key name
|
||||
@ -171,8 +180,8 @@ function sharedstate.set(key, value)
|
||||
local errormsg="sharedstate: Key " .. key .. " has not been initialized."
|
||||
error(errormsg)
|
||||
end
|
||||
pings.sharedstate_transfer(resolve_index(key), value)
|
||||
-- pings.sharedstate_ktransfer(key, value)
|
||||
pings.sharedstate_recv(resolve_index(key), value)
|
||||
-- pings.sharedstate_recv_named(key, value)
|
||||
end
|
||||
|
||||
---Send queued entries
|
||||
|
Loading…
x
Reference in New Issue
Block a user