Class: WEBrick::HTTPServer

Inherits:
Object
  • Object
show all
Defined in:
lib/webrocket/webrick-extender.rb

Instance Method Summary collapse

Instance Method Details

#_original_shutdownObject



17
# File 'lib/webrocket/webrick-extender.rb', line 17

alias _original_shutdown shutdown

#add_shutdown_listener(prc = nil, &block) ⇒ Object



12
13
14
15
# File 'lib/webrocket/webrick-extender.rb', line 12

def add_shutdown_listener(prc = nil, &block)
  @shutdown_listeners ||= []
  @shutdown_listeners.push(prc || block)
end

#mount_websocket(path, listener, subprotocol) ⇒ Object



6
7
8
9
10
# File 'lib/webrocket/webrick-extender.rb', line 6

def mount_websocket(path, listener, subprotocol)
  mount_proc(path) do |req, res|
    WEBrocket.attach(self, req, res, listener, subprotocol)
  end
end

#shutdownObject



18
19
20
21
22
23
24
25
# File 'lib/webrocket/webrick-extender.rb', line 18

def shutdown
  if @shutdown_listeners
    @shutdown_listeners.each do |listener|
      listener.call
    end
  end
  _original_shutdown
end