Compare commits

...

4 commits

Author SHA1 Message Date
Khietsly Tristan
80646eeebb chore(server): disable player buffer history in studio environment
Some checks failed
Deploy / Build & Deploy (push) Has been cancelled
2026-02-25 11:21:36 +07:00
Khietsly Tristan
704942c979 chore(repl): fast access 2026-02-25 10:49:06 +07:00
Khietsly Tristan
b26d06fa3d chore(repl): debloated prev changes made 2026-02-25 10:47:37 +07:00
khtsly
4f92248187 chore(docs): use card instead for this note 2026-02-23 12:17:02 +07:00
4 changed files with 407 additions and 453 deletions

View file

@ -10,7 +10,11 @@ local Client = Warp.Client()
## `.awaitReady` <Badge type="warning" text="yield" />
Yields the current thread until the client has successfully initialized and synchronized with the server's replication data (identifier). Its optionally, but highly recommended to call this before firing or connecting to any events to ensure the network is fully ready.
Yields the current thread until the client has successfully initialized and synchronized with the server's replication data (identifier).
::: info
Its optionally, but highly recommended to call this before firing or connecting to any events to ensure the network is fully ready.
:::
::: code-group
```luau [Variable]

View file

@ -37,7 +37,7 @@ Client.awaitReady = Replication.wait_for_ready
--@schema Buffer.SchemaType
-- Define a schema for strict data packing on a specific event.
Client.useSchema = function(remoteName: string, schema: Buffer.SchemaType)
local id = Replication.get_id(remoteName)
local id = Replication.get_id[remoteName]
if not id then
warn(`[Warp]: ".useSchema"::"{remoteName}" does not exist, likely its not registered on the server yet.`)
return
@ -49,7 +49,7 @@ end
--@fn function
-- Connect to an event to receive incoming data from the server.
Client.Connect = function(remoteName: string, fn: (Player, ...any?) -> ...any?): Connection
local id = Replication.get_id(remoteName)
local id = Replication.get_id[remoteName]
if not id then
warn(`[Warp]: ".Connect"::"{remoteName}" does not exist, likely its not registered on the server yet.`)
return { Connected = false, Disconnect = function() return end } :: Connection
@ -101,7 +101,7 @@ end
--@remoteName string
-- Disconnect all connections for a specific event.
Client.DisconnectAll = function(remoteName: string)
local id = Replication.get_id(remoteName)
local id = Replication.get_id[remoteName]
if not id then
return
end
@ -120,10 +120,10 @@ Client.Destroy = Client.DisconnectAll
--@reliable boolean
-- Fire an event to the server.
Client.Fire = function(remoteName: string, reliable: boolean, ...: any?)
local id = Replication.get_id(remoteName)
local id = Replication.get_id[remoteName]
if id then
table.insert(reliable and queueEvent or queueUnreliableEvent, {
Replication.get_id(remoteName),
Replication.get_id[remoteName],
{ ... } :: any,
})
end
@ -133,7 +133,7 @@ end
--@timeout number?
-- Invoke the server with timeout support. Yields the current thread. Returns nil if timeout occurs.
Client.Invoke = function(remoteName: string, timeout: number?, ...: any?): ...any?
local id = Replication.get_id(remoteName)
local id = Replication.get_id[remoteName]
if not id then
return nil
end

View file

@ -23,7 +23,7 @@ if RunService:IsClient() or RunService:IsRunMode() then
local contents = Buffer.readRepl(b, identifiers_schema)
if #contents == 0 then return end
for _, content in contents do
local id, remote = content[1], content[2]
local id: number, remote: string = content[1], content[2]
warp_identifier_registry.cache[remote] = id
warp_identifier_registry.name[id] = remote
@ -61,60 +61,8 @@ if RunService:IsClient() or RunService:IsRunMode() then
coroutine.yield()
end
--@name string
--@timeout number (default: 0)
Replication.get_id = function(name: string, timeout: number?): number
local cached = warp_identifier_registry.cache[name]
if cached or type(timeout) ~= "number" then return cached end
local thread = coroutine.running()
if not pending_id_yields[name] then pending_id_yields[name] = {} end
table.insert(pending_id_yields[name], thread)
task.delay(timeout, function()
if pending_id_yields[name] then
local idx = table.find(pending_id_yields[name], thread)
if idx then
table.remove(pending_id_yields[name], idx)
task.spawn(thread, nil)
end
end
end)
local obj: number = coroutine.yield()
if not obj then
warn(`[Replication] timeout: could not find identifier '{name}' after {timeout}s.`)
end
return obj
end
--@name string
--@timeout number (default: 0)
Replication.get_name = function(id: number, timeout: number?): string
local cached = warp_identifier_registry.name[id]
if cached or type(timeout) ~= "number" then return cached end
local thread = coroutine.running()
if not pending_name_yields[id] then pending_name_yields[id] = {} end
table.insert(pending_name_yields[id], thread)
task.delay(timeout, function()
if pending_name_yields[id] then
local idx = table.find(pending_name_yields[id], thread)
if idx then
table.remove(pending_name_yields[id], idx)
task.spawn(thread, nil)
end
end
end)
local obj: string = coroutine.yield()
if not id then
warn(`[Replication] timeout: could not find identifier '{id}' after {timeout}s.`)
end
return obj
end
Replication.get_id = warp_identifier_registry.cache
Replication.get_name = warp_identifier_registry.name
else
local replication_ready: { Player }, pending_replications = {}, {}
local writer: Buffer.Writer = Buffer.createWriter()

View file

@ -186,9 +186,11 @@ if RunService:IsServer() then
if type(b) ~= "buffer" then
return
end
if not RunService:IsStudio() then
local bytes: number = (player_bytes[player] or 0) + math.max(buffer.len(b), 800)
if bytes > 8e3 then return end
player_bytes[player] = bytes
end
local contents = Buffer.readEvents(b, ref, eventSchemas)
for _, content in contents do