Module: SocketIO

Defined in:
lib/SocketIO.rb

Defined Under Namespace

Classes: Client

Class Method Summary collapse

Class Method Details

.connect(uri, options = {}, &block) ⇒ Object

params [URI, String] uri



9
10
11
12
13
14
15
16
17
18
# File 'lib/SocketIO.rb', line 9

def self.connect(uri, options = {}, &block)
  uri = URI(uri)
  # handshake
  response = RestClient.get "#{uri.scheme}://#{uri.host}:#{uri.port}/socket.io/1/"
  response_array = response.split(':')
  response_array = [uri] + response_array << options
  cli = Client.new(*response_array)
  cli.instance_eval(&block) if block
  cli.start
end