Class: Rack::WebSocket::Handler::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/websocket/handler/base.rb,
lib/rack/websocket/handler/base/connection.rb

Direct Known Subclasses

Stub, Thin

Defined Under Namespace

Classes: Connection

Instance Method Summary collapse

Constructor Details

#initialize(parent, options = {}) ⇒ Base

Set application as parent and forward options


14
15
16
17
# File 'lib/rack/websocket/handler/base.rb', line 14

def initialize(parent, options = {})
  @parent = parent
  @options = options[:backend] || {}
end

Instance Method Details

#call(env) ⇒ Object

Implemented in subclass


20
21
22
# File 'lib/rack/websocket/handler/base.rb', line 20

def call(env)
  raise 'Not implemented'
end

#close_websocketObject

Implemented in subclass


30
31
32
# File 'lib/rack/websocket/handler/base.rb', line 30

def close_websocket
  raise 'Not implemented'
end

#on_closeObject

Fired when a client is disconnected.


10
# File 'lib/rack/websocket/handler/base.rb', line 10

def on_close; @parent.on_close(@env); end

#on_error(error) ⇒ Object

Fired when error occurs.


11
# File 'lib/rack/websocket/handler/base.rb', line 11

def on_error(error); @parent.on_error(@env, error); end

#on_message(msg) ⇒ Object

Fired when a message from a client is received.


9
# File 'lib/rack/websocket/handler/base.rb', line 9

def on_message(msg); @parent.on_message(@env, msg); end

#on_openObject

Fired when a client is connected.


8
# File 'lib/rack/websocket/handler/base.rb', line 8

def on_open; @parent.on_open(@env); end

#send_data(data) ⇒ Object

Implemented in subclass


25
26
27
# File 'lib/rack/websocket/handler/base.rb', line 25

def send_data(data)
  raise 'Not implemented'
end