Class: Faye::HttpTransport
- Defined in:
- lib/faye/network/transport.rb
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary
Attributes included from Logging
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Transport
#connection_type, get, #initialize, #receive, register, #retry_block, #send, supported_connection_types
Methods included from Logging
Constructor Details
This class inherits a constructor from Faye::Transport
Class Method Details
.usable?(endpoint) ⇒ Boolean
70 71 72 |
# File 'lib/faye/network/transport.rb', line 70 def self.usable?(endpoint) endpoint.is_a?(String) end |
Instance Method Details
#request(message, timeout) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/faye/network/transport.rb', line 74 def request(, timeout) retry_block = retry_block(, timeout) content = JSON.unparse() params = { :head => { 'Content-Type' => 'application/json', 'host' => URI.parse(@endpoint).host, 'Content-Length' => content.length }, :body => content, :timeout => -1 } request = EventMachine::HttpRequest.new(@endpoint).post(params) request.callback do begin receive(JSON.parse(request.response)) rescue retry_block.call end end request.errback { retry_block.call } end |