Class: Faye::WebSocket::Client
- Inherits:
-
Object
- Object
- Faye::WebSocket::Client
- Extended by:
- Forwardable
- Includes:
- API
- Defined in:
- lib/faye/websocket/client.rb
Defined Under Namespace
Modules: Connection
Constant Summary collapse
- DEFAULT_PORTS =
{ 'http' => 80, 'https' => 443, 'ws' => 80, 'wss' => 443 }
- SECURE_PROTOCOLS =
['https', 'wss']
Constants included from API
API::CLOSED, API::CLOSE_TIMEOUT, API::CLOSING, API::CONNECTING, API::OPEN, API::TYPES
Instance Attribute Summary
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.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/faye/websocket/client.rb', line 15 def initialize(url, protocols = nil, = {}) @url = url super() { ::WebSocket::Driver.client(self, :max_length => [:max_length], :protocols => protocols) } proxy = .fetch(:proxy, {}) @endpoint = URI.parse(proxy[:origin] || @url) port = @endpoint.port || DEFAULT_PORTS[@endpoint.scheme] @origin_tls = .fetch(:tls, {}) @socket_tls = proxy[:origin] ? proxy.fetch(:tls, {}) : @origin_tls configure_proxy(proxy) EventMachine.connect(@endpoint.host, port, Connection) do |conn| conn.parent = self end rescue => error on_network_error(error) end |