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::ReadyStates
API::ReadyStates::CLOSED, API::ReadyStates::CLOSING, API::ReadyStates::CONNECTING, API::ReadyStates::OPEN
Instance Attribute Summary collapse
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Attributes included from API
#buffered_amount, #ready_state, #url
Attributes included from API::EventTarget
#onclose, #onerror, #onmessage, #onopen
Instance Method Summary collapse
-
#initialize(url, protocols = nil) ⇒ Client
constructor
A new instance of Client.
Methods included from API
Methods included from API::EventTarget
#add_event_listener, #dispatch_event, #remove_event_listener
Constructor Details
#initialize(url, protocols = nil) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/faye/websocket/client.rb', line 8 def initialize(url, protocols = nil) @parser = HybiParser.new(self, :masking => true, :protocols => protocols) @url = url @uri = URI.parse(url) @protocol = '' @ready_state = CONNECTING @buffered_amount = 0 port = @uri.port || (@uri.scheme == 'wss' ? 443 : 80) EventMachine.connect(@uri.host, port, Connection) do |conn| @stream = conn conn.parent = self end end |
Instance Attribute Details
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
6 7 8 |
# File 'lib/faye/websocket/client.rb', line 6 def protocol @protocol end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/faye/websocket/client.rb', line 6 def uri @uri end |