mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 23:26:19 +00:00
Improve debug output for initialization of ServeSession
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
local Log = require(script.Parent.Parent.Log)
|
||||||
|
local Fmt = require(script.Parent.Parent.Fmt)
|
||||||
local t = require(script.Parent.Parent.t)
|
local t = require(script.Parent.Parent.t)
|
||||||
|
|
||||||
local strict = require(script.Parent.strict)
|
local strict = require(script.Parent.strict)
|
||||||
@@ -9,20 +11,38 @@ local Status = strict("Session.Status", {
|
|||||||
Disconnected = "Disconnected",
|
Disconnected = "Disconnected",
|
||||||
})
|
})
|
||||||
|
|
||||||
local function DEBUG_printPatch(patch)
|
local function DEBUG_showPatch(patch)
|
||||||
local HttpService = game:GetService("HttpService")
|
local HttpService = game:GetService("HttpService")
|
||||||
|
|
||||||
|
local output = Fmt.debugOutputBuffer()
|
||||||
|
|
||||||
|
output:push("Patch {")
|
||||||
|
output:indent()
|
||||||
|
|
||||||
for removed in ipairs(patch.removed) do
|
for removed in ipairs(patch.removed) do
|
||||||
print("Remove:", removed)
|
output:push("Remove ID %s", removed)
|
||||||
end
|
end
|
||||||
|
|
||||||
for id, added in pairs(patch.added) do
|
for id, added in pairs(patch.added) do
|
||||||
print("Add:", id, HttpService:JSONEncode(added))
|
output:push("Add ID %s {", id)
|
||||||
|
output:indent()
|
||||||
|
output:push("%s", HttpService:JSONEncode(added))
|
||||||
|
output:unindent()
|
||||||
|
output:push("}")
|
||||||
end
|
end
|
||||||
|
|
||||||
for updated in ipairs(patch.updated) do
|
for _, updated in ipairs(patch.updated) do
|
||||||
print("Update:", HttpService:JSONEncode(updated))
|
output:push("Update ID %s {", updated.id)
|
||||||
|
output:indent()
|
||||||
|
output:push("%s", HttpService:JSONEncode(updated))
|
||||||
|
output:unindent()
|
||||||
|
output:push("}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
output:unindent()
|
||||||
|
output:push("}")
|
||||||
|
|
||||||
|
return output:finish()
|
||||||
end
|
end
|
||||||
|
|
||||||
local ServeSession = {}
|
local ServeSession = {}
|
||||||
@@ -84,6 +104,8 @@ function ServeSession:__initialSync(rootInstanceId)
|
|||||||
-- the tree defined in this response.
|
-- the tree defined in this response.
|
||||||
self.__apiContext:setMessageCursor(readResponseBody.messageCursor)
|
self.__apiContext:setMessageCursor(readResponseBody.messageCursor)
|
||||||
|
|
||||||
|
Log.trace("Computing changes that plugin needs to make to catch up to server...")
|
||||||
|
|
||||||
-- Calculate the initial patch to apply to the DataModel to catch us
|
-- Calculate the initial patch to apply to the DataModel to catch us
|
||||||
-- up to what Rojo thinks the place should look like.
|
-- up to what Rojo thinks the place should look like.
|
||||||
local hydratePatch = self.__reconciler:hydrate(
|
local hydratePatch = self.__reconciler:hydrate(
|
||||||
@@ -92,6 +114,8 @@ function ServeSession:__initialSync(rootInstanceId)
|
|||||||
game
|
game
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Log.trace("Computed hydration patch: %s", DEBUG_showPatch(hydratePatch))
|
||||||
|
|
||||||
-- TODO: Prompt user to notify them of this patch, since it's
|
-- TODO: Prompt user to notify them of this patch, since it's
|
||||||
-- effectively a conflict between the Rojo server and the client.
|
-- effectively a conflict between the Rojo server and the client.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user