mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 22:11:38 +00:00
Implement sync source-only mode in ServeSession and ChangeBatcher
- Added support for a new sync mode in ServeSession that filters property changes to only include the Source property when the server indicates it is in source-only mode. - Updated ChangeBatcher to handle the new syncSourceOnly parameter, ensuring that only relevant property changes are processed based on the server's capabilities. - Enhanced API response to include sync_source_only flag, indicating the server's sync capabilities. - Adjusted related functions to accommodate the new sync logic, improving data synchronization efficiency.
This commit is contained in:
parent
8650cdbd82
commit
b30aa8280d
6 changed files with 52 additions and 8 deletions
|
|
@ -12,7 +12,7 @@ local PatchSet = require(script.Parent.Parent.PatchSet)
|
|||
|
||||
local encodePatchUpdate = require(script.Parent.encodePatchUpdate)
|
||||
|
||||
return function(instanceMap, propertyChanges)
|
||||
return function(instanceMap, propertyChanges, syncSourceOnly)
|
||||
local patch = PatchSet.newEmpty()
|
||||
|
||||
for instance, properties in propertyChanges do
|
||||
|
|
@ -30,8 +30,20 @@ return function(instanceMap, propertyChanges)
|
|||
Log.warn("Cannot sync non-nil Parent property changes yet")
|
||||
end
|
||||
else
|
||||
local update = encodePatchUpdate(instance, instanceId, properties)
|
||||
table.insert(patch.updated, update)
|
||||
if syncSourceOnly then
|
||||
-- Filter to only Source property when server is in source-only mode
|
||||
if properties.Source then
|
||||
local update = encodePatchUpdate(instance, instanceId, { Source = true })
|
||||
if update then
|
||||
table.insert(patch.updated, update)
|
||||
end
|
||||
end
|
||||
else
|
||||
local update = encodePatchUpdate(instance, instanceId, properties)
|
||||
if update then
|
||||
table.insert(patch.updated, update)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
propertyChanges[instance] = nil
|
||||
|
|
|
|||
|
|
@ -27,11 +27,16 @@ function ChangeBatcher.new(instanceMap, onChangesFlushed)
|
|||
__instanceMap = instanceMap,
|
||||
__onChangesFlushed = onChangesFlushed,
|
||||
__pendingPropertyChanges = {},
|
||||
__syncSourceOnly = false,
|
||||
}, ChangeBatcher)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function ChangeBatcher:setSyncSourceOnly(enabled)
|
||||
self.__syncSourceOnly = enabled
|
||||
end
|
||||
|
||||
function ChangeBatcher:stop()
|
||||
self.__renderSteppedConnection:Disconnect()
|
||||
self.__pendingPropertyChanges = {}
|
||||
|
|
@ -69,7 +74,7 @@ function ChangeBatcher:__flush()
|
|||
return nil
|
||||
end
|
||||
|
||||
local patch = createPatchSet(self.__instanceMap, self.__pendingPropertyChanges)
|
||||
local patch = createPatchSet(self.__instanceMap, self.__pendingPropertyChanges, self.__syncSourceOnly)
|
||||
|
||||
if PatchSet.isEmpty(patch) then
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue