forked from rojo-rbx/rojo
Two way sync V0 (#282)
* Unfinished two-way sync API * In-memory two-way sync complete * Move PatchSet application into ChangeProcessor thread, where it can be synchronous * Stop InstanceMap's signals when a ServeSession terminates * Apply patch in ChangeProcessor * Feature flag * Fix error in ChangeProcessor due to wrong drop order
This commit is contained in:
committed by
GitHub
parent
26e2e81188
commit
a398338c02
@@ -156,11 +156,22 @@ function ApiContext:read(ids)
|
||||
end
|
||||
|
||||
function ApiContext:write(patch)
|
||||
local url = ("%s/write"):format(self.__baseUrl)
|
||||
local body = Http.jsonEncode({
|
||||
local url = ("%s/api/write"):format(self.__baseUrl)
|
||||
|
||||
local body = {
|
||||
sessionId = self.__sessionId,
|
||||
patch = patch,
|
||||
})
|
||||
removed = patch.removed,
|
||||
updated = patch.updated,
|
||||
}
|
||||
|
||||
-- Only add the 'added' field if the table is non-empty, or else Roblox's
|
||||
-- JSON implementation will turn the table into an array instead of an
|
||||
-- object, causing API validation to fail.
|
||||
if next(patch.added) ~= nil then
|
||||
body.added = patch.added
|
||||
end
|
||||
|
||||
body = Http.jsonEncode(body)
|
||||
|
||||
return Http.post(url, body)
|
||||
:andThen(rejectFailedRequests)
|
||||
|
||||
Reference in New Issue
Block a user