Sha256: 98c20ae3a5e9aec2d2d7a8e698387cae0b522169a55789768aa95772c02e6e97

Contents?: true

Size: 641 Bytes

Versions: 16

Compression:

Stored size: 641 Bytes

Contents

require 'rubygems'
require File.expand_path('../../lib/faye/websocket', __FILE__)
require 'eventmachine'

port   = ARGV[0] || 7000
secure = ARGV[1] == 'ssl'

EM.run {
  scheme = secure ? 'wss' : 'ws'
  url    = "#{scheme}://localhost:#{port}/"
  socket = Faye::WebSocket::Client.new(url)
  
  puts "Connecting to #{socket.url}"
  
  socket.onopen = lambda do |event|
    p [:open]
    socket.send("Hello, WebSocket!")
  end
  
  socket.onmessage = lambda do |event|
    p [:message, event.data]
    # socket.close 1002, 'Going away'
  end
  
  socket.onclose = lambda do |event|
    p [:close, event.code, event.reason]
    EM.stop
  end
}

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
faye-websocket-0.4.6-java examples/client.rb
faye-websocket-0.4.6 examples/client.rb
faye-websocket-0.4.5-java examples/client.rb
faye-websocket-0.4.5 examples/client.rb
_bushido-faye-websocket-0.4.4 examples/client.rb
faye-websocket-0.4.4-java examples/client.rb
faye-websocket-0.4.4 examples/client.rb
faye-websocket-0.4.3 examples/client.rb
faye-websocket-0.4.2 examples/client.rb
faye-websocket-0.4.1 examples/client.rb
faye-websocket-0.4.0 examples/client.rb
faye-websocket-0.3.0 examples/client.rb
faye-websocket-0.2.0 examples/client.rb
faye-websocket-0.1.2 examples/client.rb
faye-websocket-0.1.1 examples/client.rb
faye-websocket-0.1.0 examples/client.rb