Sha256: 1c8766352cb30520992a4b7be58217573e0073d003827f335b6f75c688300ca2

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

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

EM.run {
  url   = ARGV[0]
  proxy = ARGV[1]

  ws = Faye::WebSocket::Client.new(url, [],
    :proxy      => { :origin => proxy, :headers => { 'User-Agent' => 'Echo' } },
    :headers    => { 'Origin' => 'http://faye.jcoglan.com' },
    :extensions => [PermessageDeflate]
  )

  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

1 entries across 1 versions & 1 rubygems

Version Path
faye-websocket-0.10.9 examples/client.rb