Expose reconciler hooks on servesession (#741)

This commit is contained in:
boatbomber
2023-07-16 21:03:06 -07:00
committed by GitHub
parent 8662d2227c
commit 4915477823
2 changed files with 7 additions and 11 deletions

View File

@@ -374,7 +374,7 @@ function App:startSession()
end)
end)
serveSession:onPatchApplied(function(patch, unapplied)
serveSession:hookPostcommit(function(patch, _instanceMap, unapplied)
local now = os.time()
local old = self.state.patchData

View File

@@ -97,7 +97,6 @@ function ServeSession.new(options)
__instanceMap = instanceMap,
__changeBatcher = changeBatcher,
__statusChangedCallback = nil,
__patchAppliedCallback = nil,
__connections = connections,
}
@@ -129,8 +128,12 @@ function ServeSession:setConfirmCallback(callback)
self.__userConfirmCallback = callback
end
function ServeSession:onPatchApplied(callback)
self.__patchAppliedCallback = callback
function ServeSession:hookPrecommit(callback)
return self.__reconciler:hookPrecommit(callback)
end
function ServeSession:hookPostcommit(callback)
return self.__reconciler:hookPostcommit(callback)
end
function ServeSession:start()
@@ -291,9 +294,6 @@ function ServeSession:__initialSync(serverInfo)
Log.warn("Could not apply all changes requested by the Rojo server:\n{}",
PatchSet.humanSummary(self.__instanceMap, unappliedPatch))
end
if self.__patchAppliedCallback then
pcall(self.__patchAppliedCallback, catchUpPatch, unappliedPatch)
end
end
end)
end
@@ -318,10 +318,6 @@ function ServeSession:__mainSyncLoop()
Log.warn("Could not apply all changes requested by the Rojo server:\n{}",
PatchSet.humanSummary(self.__instanceMap, unappliedPatch))
end
if self.__patchAppliedCallback then
pcall(self.__patchAppliedCallback, message, unappliedPatch)
end
end
end):await()