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
Attributes included from API
#buffered_amount, #ready_state, #url
Instance Method Summary collapse
-
#initialize(url, protocols = nil) ⇒ 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) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/faye/websocket/client.rb', line 7 def initialize(url, protocols = nil) @url = url @uri = URI.parse(url) @driver = ::WebSocket::Driver.client(self, :protocols => protocols) super() port = @uri.port || (@uri.scheme == 'wss' ? 443 : 80) EventMachine.connect(@uri.host, port, Connection) do |conn| @stream = conn conn.parent = self end end |