Class: TorqueBox::Stomp::StompJavascriptClientProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/torquebox/stomp/rack/stomp_javascript_client_provider.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ StompJavascriptClientProvider

Returns a new instance of StompJavascriptClientProvider.



23
24
25
# File 'lib/torquebox/stomp/rack/stomp_javascript_client_provider.rb', line 23

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/torquebox/stomp/rack/stomp_javascript_client_provider.rb', line 27

def call(env)
  path_info = env['PATH_INFO']
  if ( path_info == '/stilts-stomp.js' )
    return javascript_client_response
  else
    return @app.call( env )
  end
end

#javascript_client_responseObject



36
37
38
39
40
41
42
# File 'lib/torquebox/stomp/rack/stomp_javascript_client_provider.rb', line 36

def javascript_client_response
  js = File.read( File.join( File.dirname(__FILE__), 'stilts-stomp-client-js.js' ) )
  [ 200,
    { 'Content-Length' => "#{js.size}",
      'Content-Type'   => 'text/plain' },
    [js] ]
end