Class: Joyce::Server
- Inherits:
-
Object
- Object
- Joyce::Server
- Defined in:
- lib/joyce.rb
Class Method Summary collapse
Instance Method Summary collapse
- #boot ⇒ Object
- #drive! ⇒ Object
- #halt! ⇒ Object
- #join ⇒ Object
- #received_commands ⇒ Object
- #setup ⇒ Object
- #sim ⇒ Object
- #tick ⇒ Object
Class Method Details
.kickstart! ⇒ Object
112 113 114 115 116 |
# File 'lib/joyce.rb', line 112 def kickstart! server = new server.boot server end |
Instance Method Details
#boot ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/joyce.rb', line 72 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! ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/joyce.rb', line 89 def drive! @driving = true Thread.new do while @driving tick sleep 0.05 end end end |
#halt! ⇒ Object
99 100 101 |
# File 'lib/joyce.rb', line 99 def halt! @driving = false end |
#join ⇒ Object
81 82 83 |
# File 'lib/joyce.rb', line 81 def join @cmd_thread.join end |
#received_commands ⇒ Object
107 108 109 |
# File 'lib/joyce.rb', line 107 def received_commands sim.received_commands end |
#setup ⇒ Object
68 69 70 |
# File 'lib/joyce.rb', line 68 def setup # p [ :server_setup ] end |
#sim ⇒ Object
103 104 105 |
# File 'lib/joyce.rb', line 103 def sim @simulation ||= Metacosm::Simulation.current end |
#tick ⇒ Object
85 86 87 |
# File 'lib/joyce.rb', line 85 def tick # p [ :server_tick ] end |