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
136 137 138 139 140 |
# File 'lib/joyce.rb', line 136 def kickstart! server = new server.boot server end |
Instance Method Details
#boot ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/joyce.rb', line 96 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
113 114 115 116 117 118 119 120 121 |
# File 'lib/joyce.rb', line 113 def drive! @driving = true Thread.new do while @driving tick sleep 0.05 end end end |
#halt! ⇒ Object
123 124 125 |
# File 'lib/joyce.rb', line 123 def halt! @driving = false end |
#join ⇒ Object
105 106 107 |
# File 'lib/joyce.rb', line 105 def join @cmd_thread.join end |
#received_commands ⇒ Object
131 132 133 |
# File 'lib/joyce.rb', line 131 def received_commands sim.received_commands end |
#setup ⇒ Object
92 93 94 |
# File 'lib/joyce.rb', line 92 def setup # p [ :server_setup ] end |
#sim ⇒ Object
127 128 129 |
# File 'lib/joyce.rb', line 127 def sim @simulation ||= Metacosm::Simulation.current end |
#tick ⇒ Object
109 110 111 |
# File 'lib/joyce.rb', line 109 def tick # p [ :server_tick ] end |