mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 22:11:38 +00:00
Add initial sync complete callback to ServeSession for one-shot mode handling
- Introduced `__initialSyncCompleteCallback` in `ServeSession` to manage actions after the initial sync is complete. - Updated `App:startSession` to set the callback, ensuring proper disconnection after initial sync in one-shot mode. - Refactored comments in `App:startSession` for clarity on sync behavior and disconnection logic.
This commit is contained in:
parent
29b0b9ad34
commit
249e26367b
3 changed files with 24 additions and 21 deletions
|
|
@ -116,6 +116,7 @@ function ServeSession.new(options)
|
|||
__statusChangedCallback = nil,
|
||||
__userConfirmCallback = nil,
|
||||
__patchUpdateCallback = nil,
|
||||
__initialSyncCompleteCallback = nil,
|
||||
__serverInfo = nil,
|
||||
__confirmingPatch = nil,
|
||||
__connections = connections,
|
||||
|
|
@ -156,6 +157,10 @@ function ServeSession:setPatchUpdateCallback(callback)
|
|||
self.__patchUpdateCallback = callback
|
||||
end
|
||||
|
||||
function ServeSession:setInitialSyncCompleteCallback(callback)
|
||||
self.__initialSyncCompleteCallback = callback
|
||||
end
|
||||
|
||||
function ServeSession:setUpdateLoadingTextCallback(callback)
|
||||
self.__updateLoadingText = callback
|
||||
end
|
||||
|
|
@ -306,6 +311,12 @@ function ServeSession:start()
|
|||
return self:__confirmAndApplyInitialPatch(catchUpPatch, serverInfo)
|
||||
end)
|
||||
end)
|
||||
:andThen(function()
|
||||
-- Initial sync is fully complete (including any writes to the server)
|
||||
if self.__initialSyncCompleteCallback ~= nil then
|
||||
self.__initialSyncCompleteCallback()
|
||||
end
|
||||
end)
|
||||
:catch(function(err)
|
||||
if self.__status ~= Status.Disconnected then
|
||||
self:__stopInternal(err)
|
||||
|
|
@ -658,11 +669,8 @@ function ServeSession:__confirmAndApplyInitialPatch(catchUpPatch, serverInfo)
|
|||
if selection == "push" then
|
||||
-- Apply Rojo removal to Studio
|
||||
table.insert(pushPatch.removed, idOrInstance)
|
||||
elseif selection == "pull" and self.__twoWaySync then
|
||||
-- Don't remove in Studio, but we can't easily "add back" to Rojo
|
||||
-- For now, just skip (similar to ignore)
|
||||
end
|
||||
-- "ignore" items are skipped
|
||||
-- "pull" skipped: can't easily "add back" to Rojo, same as "ignore"
|
||||
end
|
||||
|
||||
-- Process added items
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue