examples/autobahn_client.rb in faye-websocket-0.4.7-java vs examples/autobahn_client.rb in faye-websocket-0.5.0
- old
+ new
@@ -1,15 +1,17 @@
require 'rubygems'
-require File.expand_path('../../lib/faye/websocket', __FILE__)
+require 'bundler/setup'
+require 'faye/websocket'
require 'cgi'
require 'progressbar'
EM.run {
- host = 'ws://localhost:9001'
- agent = "Ruby #{RUBY_VERSION}"
- cases = 0
- skip = []
+ host = 'ws://localhost:9001'
+ ruby = RUBY_PLATFORM =~ /java/ ? 'JRuby' : 'MRI'
+ agent = "#{ruby} #{RUBY_VERSION}"
+ cases = 0
+ skip = []
socket = Faye::WebSocket::Client.new("#{host}/getCaseCount")
progress = nil
socket.onmessage = lambda do |event|
@@ -35,10 +37,10 @@
socket.onmessage = lambda do |event|
socket.send(event.data)
end
- socket.onclose = lambda do |event|
+ socket.on :close do |event|
run_case.call(n + 1)
end
end
end