Class: Cyperful::UiServer
- Inherits:
-
Object
- Object
- Cyperful::UiServer
- Defined in:
- lib/cyperful/ui_server.rb
Defined Under Namespace
Classes: ReverseProxy
Instance Method Summary collapse
-
#initialize(port:) ⇒ UiServer
constructor
A new instance of UiServer.
- #notify(data) ⇒ Object
- #on_command(&block) ⇒ Object
- #shutdown ⇒ Object
- #start_async ⇒ Object
- #url_origin ⇒ Object
Constructor Details
#initialize(port:) ⇒ UiServer
Returns a new instance of UiServer.
14 15 16 17 18 19 20 |
# File 'lib/cyperful/ui_server.rb', line 14 def initialize(port:) @port = port @notify_queue = Queue.new build_server end |
Instance Method Details
#notify(data) ⇒ Object
26 27 28 |
# File 'lib/cyperful/ui_server.rb', line 26 def notify(data) @notify_queue.enq(data) end |
#on_command(&block) ⇒ Object
30 31 32 |
# File 'lib/cyperful/ui_server.rb', line 30 def on_command(&block) @on_command = block end |
#shutdown ⇒ Object
144 145 146 147 148 |
# File 'lib/cyperful/ui_server.rb', line 144 def shutdown @thread&.kill @server.shutdown end |
#start_async ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'lib/cyperful/ui_server.rb', line 135 def start_async # start server in background i.e. non-blocking @thread = Thread.new do Thread.current.abort_on_exception = true @server.start end end |
#url_origin ⇒ Object
22 23 24 |
# File 'lib/cyperful/ui_server.rb', line 22 def url_origin "http://localhost:#{@port}" end |