-
-
Save charlesvallieres/0785c76009440cf5098e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_support" | |
require "active_support/all" | |
require "faye/websocket" | |
require "eventmachine" | |
threads = [] | |
begin | |
threads = (1..200).map do |i| | |
Thread.new do | |
EM.run do | |
ws = Faye::WebSocket::Client.new('ws://127.0.0.1:8105/websocket') | |
ws.on :open do |event| | |
p [:open] | |
ws.send({ msg: "connect", version: "pre2", support: ["pre2"] }.to_json) | |
end | |
ws.on :message do |event| | |
p [:message, event.data] | |
end | |
ws.on :close do |event| | |
p [:close, event.code, event.reason] | |
ws = nil | |
end | |
end | |
end | |
end | |
threads.each { |t| t.join } | |
rescue Interrupt => e | |
threads.each do |t| | |
Thread.kill(t) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment