Class: AnyCable::Rack::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/anycable/rack/middleware.rb

Overview

:nodoc:

Constant Summary collapse

PROTOCOLS =
["actioncable-v1-json", "actioncable-unsupported"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pinger:, hub:, coder:, rpc_client:, header_names:) ⇒ Middleware

Returns a new instance of Middleware.



19
20
21
22
23
24
25
# File 'lib/anycable/rack/middleware.rb', line 19

def initialize(pinger:, hub:, coder:, rpc_client:, header_names:)
  @pinger = pinger
  @hub = hub
  @coder = coder
  @rpc_client = rpc_client
  @header_names = header_names
end

Instance Attribute Details

#coderObject (readonly)

Returns the value of attribute coder.



13
14
15
# File 'lib/anycable/rack/middleware.rb', line 13

def coder
  @coder
end

#header_namesObject (readonly)

Returns the value of attribute header_names.



13
14
15
# File 'lib/anycable/rack/middleware.rb', line 13

def header_names
  @header_names
end

#hubObject (readonly)

Returns the value of attribute hub.



13
14
15
# File 'lib/anycable/rack/middleware.rb', line 13

def hub
  @hub
end

#pingerObject (readonly)

Returns the value of attribute pinger.



13
14
15
# File 'lib/anycable/rack/middleware.rb', line 13

def pinger
  @pinger
end

#rpc_clientObject (readonly)

Returns the value of attribute rpc_client.



13
14
15
# File 'lib/anycable/rack/middleware.rb', line 13

def rpc_client
  @rpc_client
end

Instance Method Details

#call(env) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/anycable/rack/middleware.rb', line 27

def call(env)
  return not_found unless websocket?(env)

  rack_hijack(env)
  listen_socket(env)

  [-1, {}, []]
end