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
119 120 121 122 123 |
# File 'lib/joyce.rb', line 119 def kickstart! server = new server.boot server end |
Instance Method Details
#boot ⇒ Object
79 80 81 82 83 84 85 86 |
# 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! ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'lib/joyce.rb', line 96 def drive! @driving = true Thread.new do while @driving tick sleep 0.05 end end end |
#halt! ⇒ Object
106 107 108 |
# File 'lib/joyce.rb', line 106 def halt! @driving = false end |
#join ⇒ Object
88 89 90 |
# File 'lib/joyce.rb', line 88 def join @cmd_thread.join end |
#received_commands ⇒ Object
114 115 116 |
# File 'lib/joyce.rb', line 114 def received_commands sim.received_commands end |
#setup ⇒ Object
75 76 77 |
# File 'lib/joyce.rb', line 75 def setup # p [ :server_setup ] end |
#sim ⇒ Object
110 111 112 |
# File 'lib/joyce.rb', line 110 def sim @simulation ||= Metacosm::Simulation.current end |
#tick ⇒ Object
92 93 94 |
# File 'lib/joyce.rb', line 92 def tick # p [ :server_tick ] end |