Class: Faye::WebSocket::Client
- Inherits:
-
Object
- Object
- Faye::WebSocket::Client
- Includes:
- API
- Defined in:
- lib/faye/websocket/client.rb
Defined Under Namespace
Modules: Connection
Constant Summary
Constants included from API
API::CLOSED, API::CLOSING, API::CONNECTING, API::OPEN
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Attributes included from API
#buffered_amount, #ready_state, #url
Instance Method Summary collapse
-
#initialize(url, protocols = nil, options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from API
#close, #ping, #protocol, #send, #write
Methods included from API::EventTarget
#add_event_listener, #add_listener, #dispatch_event, #remove_event_listener
Constructor Details
#initialize(url, protocols = nil, options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/faye/websocket/client.rb', line 9 def initialize(url, protocols = nil, = {}) @url = url @uri = URI.parse(url) @driver = ::WebSocket::Driver.client(self, :max_length => [:max_length], :protocols => protocols) [:open, :error].each do |event| @driver.on(event) do @headers = @driver.headers @status = @driver.status end end super() port = @uri.port || (@uri.scheme == 'wss' ? 443 : 80) EventMachine.connect(@uri.host, port, Connection) do |conn| @stream = conn conn.parent = self end rescue => error event = Event.new('error', :message => "Network error: #{url}: #{error.}") event.init_event('error', false, false) dispatch_event(event) finalize(error., 1006) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/faye/websocket/client.rb', line 7 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/faye/websocket/client.rb', line 7 def status @status end |