Module: EventMachine::WebSocket

Defined in:
lib/web-repl/patch.rb

Class Method Summary collapse

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(options = {}, &block)
  host, port = options.values_at(:host, :port)
  EM.start_server(host, port, Connection, options) 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(options = {}, &block)
  trap("TERM") { stop }
  trap("INT")  { stop }
  run(options, &block)
end

.run(options = {}, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/web-repl/patch.rb', line 15

def self.run(options = {}, &block)
  if EM.reactor_running?
    handle_run(options, &block)
  else
    EM.run { handle_run(options, &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(options = {}, &block)
  EM.epoll
  if EM.reactor_running?
    handle_start(options, &block)
  else
    EM.run { handle_start(options, &block) }
  end
end