class Joyce::Server

Public Class Methods

kickstart!() click to toggle source
# File lib/joyce.rb, line 119
def kickstart!
  server = new
  server.boot
  server
end

Public Instance Methods

boot() click to toggle source
# File lib/joyce.rb, line 79
def boot
  sim.on_event(publish_to: EVENT_STREAM)
  @cmd_thread = sim.subscribe_for_commands(channel: COMMAND_QUEUE)
  setup
  sim.conduct!
  drive!
  # cmd_thread.join
end
drive!() click to toggle source
# File lib/joyce.rb, line 96
def drive!
  @driving = true
  Thread.new do
    while @driving
      tick
      sleep 0.05
    end
  end
end
halt!() click to toggle source
# File lib/joyce.rb, line 106
def halt!
  @driving = false
end
join() click to toggle source
# File lib/joyce.rb, line 88
def join
  @cmd_thread.join
end
received_commands() click to toggle source
# File lib/joyce.rb, line 114
def received_commands
  sim.received_commands
end
setup() click to toggle source
# File lib/joyce.rb, line 75
def setup
  # p [ :server_setup ]
end
sim() click to toggle source
# File lib/joyce.rb, line 110
def sim
  @simulation ||= Metacosm::Simulation.current
end
tick() click to toggle source
# File lib/joyce.rb, line 92
def tick
  # p [ :server_tick ]
end