Module: EventMachine::WebSocket

Defined in:
lib/em-websocket/handler.rb,
lib/em-websocket/debugger.rb,
lib/em-websocket/handler75.rb,
lib/em-websocket/handler76.rb,
lib/em-websocket/websocket.rb,
lib/em-websocket/handler_factory.rb

Defined Under Namespace

Modules: Debugger Classes: DataError, Handler, Handler75, Handler76, HandlerFactory, HandshakeError, WebSocketError

Class Method Summary collapse

Class Method Details

.start(options, &blk) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/em-websocket/websocket.rb', line 7

def self.start(options, &blk)
  EM.epoll
  EM.run do

    trap("TERM") { stop }
    trap("INT")  { stop }

    EventMachine::start_server(options[:host], options[:port],
      EventMachine::WebSocket::Connection, options) do |c|
      blk.call(c)
    end
  end
end

.stopObject



21
22
23
24
# File 'lib/em-websocket/websocket.rb', line 21

def self.stop
  puts "Terminating WebSocket Server"
  EventMachine.stop
end