Class: Faye::WebSocket::Client

Inherits:
Object
  • Object
show all
Includes:
API
Defined in:
lib/faye/util/web_socket/client.rb

Defined Under Namespace

Modules: Connection

Instance Attribute Summary collapse

Attributes included from API

#buffered_amount, #onclose, #onerror, #onmessage, #onopen, #ready_state, #url

Instance Method Summary collapse

Methods included from API

#add_event_listener, #close, #dispatch_event, #receive, #remove_event_listener, #send

Methods included from Publisher

#bind, #count_listeners, #trigger, #unbind

Constructor Details

#initialize(url) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/faye/util/web_socket/client.rb', line 8

def initialize(url)
  @parser = Protocol8Parser.new(self, :masking => true)
  @url    = url
  @uri    = URI.parse(url)
  
  @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

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/faye/util/web_socket/client.rb', line 6

def uri
  @uri
end