Class: AnyCable::Rack::Middleware

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

Overview

:nodoc:

Constant Summary collapse

PROTOCOLS =
%w[actioncable-v1-json actioncable-v1-ext-json actioncable-v1-msgpack actioncable-unsupported actioncable-v1-protobuf].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.



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

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.



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

def coder
  @coder
end

#header_namesObject (readonly)

Returns the value of attribute header_names.



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

def header_names
  @header_names
end

#hubObject (readonly)

Returns the value of attribute hub.



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

def hub
  @hub
end

#pingerObject (readonly)

Returns the value of attribute pinger.



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

def pinger
  @pinger
end

#rpc_clientObject (readonly)

Returns the value of attribute rpc_client.



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

def rpc_client
  @rpc_client
end

Instance Method Details

#call(env) ⇒ Object



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

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

  rack_hijack(env)
  listen_socket(env)

  [-1, {}, []]
end