Sha256: f6430bc00ac780d0cb2da031ac0316842f7fb0badb108be628d821a3955f153e

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 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

2 entries across 2 versions & 1 rubygems

Version Path
faye-websocket-0.4.7-java examples/client.rb
faye-websocket-0.4.7 examples/client.rb