module EventMachine::WebSocket

Attributes

close_timeout[RW]
max_frame_size[RW]

Public Class Methods

run(options) { |c| ... } click to toggle source

Start WebSocket server inside eventmachine run loop

# File lib/em-websocket/websocket.rb, line 44
def self.run(options)
  host, port = options.values_at(:host, :port)
  EM.start_server(host, port, Connection, options) do |c|
    yield c
  end
end
start(options, &blk) click to toggle source

Start WebSocket server, including starting eventmachine run loop

# File lib/em-websocket/websocket.rb, line 33
def self.start(options, &blk)
  EM.epoll
  EM.run {
    trap("TERM") { stop }
    trap("INT")  { stop }

    run(options, &blk)
  }
end
stop() click to toggle source
# File lib/em-websocket/websocket.rb, line 51
def self.stop
  puts "Terminating WebSocket Server"
  EM.stop
end