Class: Agoo::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/agoo/client.rb

Overview

A WebSocket/SSE middleware class. If a WebSocket connection has been requested by a JavaScript listener then a success status (200) is returned by the call method otherwise a 404 status is returned.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler_class) ⇒ Client

Returns a new instance of Client.



10
11
12
# File 'lib/agoo/client.rb', line 10

def initialize(handler_class)
  @handler_class = handler_class
end

Instance Attribute Details

#handler_classObject

Returns the value of attribute handler_class.



8
9
10
# File 'lib/agoo/client.rb', line 8

def handler_class
  @handler_class
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/agoo/client.rb', line 14

def call(env)
  unless env['rack.upgrade?'].nil?
	env['rack.upgrade'] = @handler_class.new(env)
	[ 200, { }, [ ] ]
  else
	[ 404, { }, [ ] ]
  end
end