Class: AnyCable::RackServer::Middleware

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_app, pinger:, hub:, coder:, rpc_host:, headers:, server_id:) ⇒ Middleware

Returns a new instance of Middleware.



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

def initialize(_app, pinger:, hub:, coder:, rpc_host:, headers:, server_id:)
  @pinger    = pinger
  @hub       = hub
  @coder     = coder
  @rpc_host  = rpc_host
  @headers   = headers
  @server_id = server_id
end

Instance Attribute Details

#coderObject (readonly)

Returns the value of attribute coder.



11
12
13
# File 'lib/anycable/rack-server/middleware.rb', line 11

def coder
  @coder
end

#headersObject (readonly)

Returns the value of attribute headers.



11
12
13
# File 'lib/anycable/rack-server/middleware.rb', line 11

def headers
  @headers
end

#hubObject (readonly)

Returns the value of attribute hub.



11
12
13
# File 'lib/anycable/rack-server/middleware.rb', line 11

def hub
  @hub
end

#pingerObject (readonly)

Returns the value of attribute pinger.



11
12
13
# File 'lib/anycable/rack-server/middleware.rb', line 11

def pinger
  @pinger
end

#rpc_hostObject (readonly)

Returns the value of attribute rpc_host.



11
12
13
# File 'lib/anycable/rack-server/middleware.rb', line 11

def rpc_host
  @rpc_host
end

#server_idObject (readonly)

Returns the value of attribute server_id.



11
12
13
# File 'lib/anycable/rack-server/middleware.rb', line 11

def server_id
  @server_id
end

Instance Method Details

#call(env) ⇒ Object



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

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

  rack_hijack(env)
  listen_socket(env)

  [-1, {}, []]
end