Module: EventMachine::WebSocket
- Defined in:
- lib/web-repl/patch.rb
Class Method Summary collapse
- .handle_run(options = {}, &block) ⇒ Object
- .handle_start(options = {}, &block) ⇒ Object
- .run(options = {}, &block) ⇒ Object
- .start(options = {}, &block) ⇒ Object
Class Method Details
.handle_run(options = {}, &block) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/web-repl/patch.rb', line 25 def self.handle_run( = {}, &block) host, port = .values_at(:host, :port) EM.start_server(host, port, Connection, ) do |c| yield c end end |
.handle_start(options = {}, &block) ⇒ Object
32 33 34 35 36 |
# File 'lib/web-repl/patch.rb', line 32 def self.handle_start( = {}, &block) trap("TERM") { stop } trap("INT") { stop } run(, &block) end |
.run(options = {}, &block) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/web-repl/patch.rb', line 15 def self.run( = {}, &block) if EM.reactor_running? handle_run(, &block) else EM.run { handle_run(, &block) } end end |
.start(options = {}, &block) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/web-repl/patch.rb', line 6 def self.start( = {}, &block) EM.epoll if EM.reactor_running? handle_start(, &block) else EM.run { handle_start(, &block) } end end |