Class: TorqueBox::Stomp::StompJavascriptClientProvider

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

Instance Method Summary (collapse)

Constructor Details

- (StompJavascriptClientProvider) initialize(app)

Returns a new instance of StompJavascriptClientProvider



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

def initialize(app)
  @app = app
end

Instance Method Details

- (Object) call(env)



27
28
29
30
31
32
33
34
# File 'stomp/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

- (Object) javascript_client_response



36
37
38
39
40
41
42
# File 'stomp/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