Sha256: e0e8f74f936d5090560a5ddb7be9d629df6916492c8a5b92d8252e030ca44a58

Contents?: true

Size: 662 Bytes

Versions: 4

Compression:

Stored size: 662 Bytes

Contents

require 'rubygems'
require 'bundler/setup'
require 'faye/websocket'
require 'eventmachine'

EM.run {
  url     = ARGV[0]
  headers = {'Origin' => 'http://faye.jcoglan.com'}
  proxy   = {:origin => ARGV[1], :headers => {'User-Agent' => 'Echo'}}
  ws      = Faye::WebSocket::Client.new(url, nil, :headers => headers, :proxy => proxy)

  ws.onopen = lambda do |event|
    p [:open, ws.headers]
    ws.send('mic check')
  end

  ws.onclose = lambda do |close|
    p [:close, close.code, close.reason]
    EM.stop
  end

  ws.onerror = lambda do |error|
    p [:error, error.message]
  end

  ws.onmessage = lambda do |message|
    p [:message, message.data]
  end
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
faye-websocket-0.9.2 examples/client.rb
faye-websocket-0.9.1 examples/client.rb
faye-websocket-0.9.0 examples/client.rb
faye-websocket-0.8.0 examples/client.rb