Sha256: fb9838c3d0130b54affdfb22c18aec210b03e3c36c23a5f755f4fd3eb5d8c2c3
Contents?: true
Size: 972 Bytes
Versions: 6
Compression:
Stored size: 972 Bytes
Contents
module GameMachine class GridReplicator < Actor::Base def post_init(*args) @paths = {} #schedule_update(80) end def on_receive(message) if message.is_a?(String) delta = Grid.default_grid.current_delta return if delta.length == 0 GameMachine::ClusterMonitor.remote_members.keys.each do |address| @paths[address] ||= "#{address}#{self.class.local_path(self.class.name)}" Actor::Ref.new(@paths[address],self.class.name).tell(delta) end else Grid.default_grid.update_from_delta(message) end end def schedule_update(update_interval) duration = GameMachine::JavaLib::Duration.create(update_interval, java.util.concurrent.TimeUnit::MILLISECONDS) scheduler = get_context.system.scheduler dispatcher = get_context.system.dispatcher scheduler.schedule(duration, duration, get_self, "replicate_grid", dispatcher, nil) end end end
Version data entries
6 entries across 6 versions & 1 rubygems