diff Comm.lua @ 105:c6c748a5823b tip

Collaborative list trimming 80% functional Updates for the zone-in problem
author John@Yosemite-PC
date Sun, 06 May 2012 08:33:34 -0400
parents 21567b74fcc7
children
line wrap: on
line diff
--- a/Comm.lua	Sun May 06 08:30:15 2012 -0400
+++ b/Comm.lua	Sun May 06 08:33:34 2012 -0400
@@ -111,7 +111,7 @@
 
             local success, o = CreateChangeDiff(remoteBase,t)
             if success and getn(o) > 0 then
-                Send("CU",o)
+                Send("CU",{remoteBase,o})
             end
             if not success then -- push
                 print("Received request at differing timebase",remoteBase,db.profile.time," ... pushing")
@@ -122,7 +122,10 @@
 
     ["CU"] = function(self,packet,sender,isloop) -- blindly trust an admin loot master
         if isloop then return end
-        IntegrateChangeDiff(packet)
+        local base,changes = unpack(packet)
+        if base and base > 0 and changes and getn(changes) > 0 then
+            IntegrateChangeDiff(base,changes)
+        end
     end,
 
     ["RequestCatchup"] = function(self,from) -- todo: integrate from
@@ -153,14 +156,16 @@
         print("SA")
         if isloop then return end
         if admin then
-            SendAdmin("SR",onloadAdminStatus) -- SR ... prevent infinite loop please
+            -- todo: only send back a diff. this is barbaric.
+            SendAdmin("SR",{onloadAdminStatus,db.profile.time,db.profile.changes}) -- SR ... prevent infinite loop please
             RemoteAdminUpdateReceived(sender,packet)
         end
     end,
 
     ["SendAdminStatusTable"] = function(self)
         if admin then
-            SendAdmin("SA",onloadAdminStatus) -- only send onload status, since that's the only data you're guaranteed to have safely safed
+            SendAdmin("SA",{onloadAdminStatus,db.profile.time}) -- only send onload status, since that's the only data you're guaranteed to have safely saved
+            -- todo: see whether the above comment is correct, or the code
         end
     end,
 }