Class: SockJS::Transports::Info::Get

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/sockjs/transports/info.rb

Instance Attribute Summary

Attributes inherited from Endpoint

#connection, #options

Attributes included from Endpoint::ClassMethods

#method, #prefix

Instance Method Summary collapse

Methods inherited from Endpoint

#build_error_response, #build_response, #call, #empty_string, #error_content_type, #format_frame, #handle, #handle_http_error, #handle_request, #initialize, #inspect, #response_class

Methods included from Endpoint::ClassMethods

#add_route, #add_routes, #endpoints, #register, #route_conditions, #routing_prefix

Constructor Details

This class inherits a constructor from SockJS::Endpoint

Instance Method Details

#entropyObject



29
30
31
# File 'lib/sockjs/transports/info.rb', line 29

def entropy
  rand(1 << 32)
end

#infoObject



20
21
22
23
24
25
26
27
# File 'lib/sockjs/transports/info.rb', line 20

def info
  {
    websocket: @options[:websocket],
    origins: ["*:*"], # As specified by the spec, currently ignored.
    cookie_needed: @options[:cookie_needed],
    entropy: self.entropy
  }
end

#setup_response(request, response) ⇒ Object

Handler.



11
12
13
14
15
16
17
18
# File 'lib/sockjs/transports/info.rb', line 11

def setup_response(request, response)
  response.status = 200
  response.set_content_type(:json)
  response.set_access_control(request.origin)
  response.set_allow_options_post
  response.set_no_cache
  response.write(self.info.to_json)
end