patcher.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. Patcher = class()
  2. function Patcher:load()
  3. self.hashes = {}
  4. self.hasherThread = love.thread.newThread('app/thread/hasher.lua')
  5. self.hasherOut = love.thread.getChannel('hasher.out')
  6. self.hasherThread:start()
  7. end
  8. function Patcher:update()
  9. repeat
  10. local hashed = self.hasherOut:pop()
  11. if hashed == 'done' then
  12. self.hash = self.hasherOut:pop()
  13. self:doneHashing(self.hash)
  14. elseif type(hashed) == 'table' then
  15. table.insert(self.hashes, hashed)
  16. end
  17. until not hashed
  18. if self.hasherThread:getError() then
  19. print(self.hasherThread:getError())
  20. end
  21. if self.patcherThread then
  22. repeat
  23. local response = self.patcherChannel:pop()
  24. if response then
  25. -- Crazy zip shit
  26. end
  27. until not response
  28. if self.patcherThread:getError() then
  29. print(self.patcherThread:getError())
  30. end
  31. end
  32. end
  33. function Patcher:doneHashing(hash)
  34. -- Send to the Hub.
  35. self.patcherThread = love.thread.newThread('app/thread/patcher.lua')
  36. self.patcherChannel = love.thread.getChannel('patcher.response')
  37. self.patcherThread:start(self.hash, json.encode(self.hashes))
  38. end