Skip to content

Instantly share code, notes, and snippets.

@danopia
Created May 7, 2011 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danopia/5c4769f21486a3c34d6a to your computer and use it in GitHub Desktop.
Save danopia/5c4769f21486a3c34d6a to your computer and use it in GitHub Desktop.
require 'lib/web_socket.rb'
require 'digest/md5'
md5 = Digest::MD5.new
require 'rubygems'
require 'json'
100.times do
# Connects to Web Socket server at host example.com port 10081.
clients = (1..5).to_a.map{|x| p x; [x,WebSocket.new("ws://69.195.198.92:8080/server")]}
5.times do |i|
clients.each do |c|
sleep 1
time = Time.now
time_str = time.strftime('%a %b %d %Y %T GMT%z (EDT)')
data = {
:key=>md5.hexdigest("js_#{time_str}"),
:message=>"This is spam. " * 75,
#:message=>"<a><a><a><a><a> " * 50,
:name=>"danobot-#{c[0]}",
:gravatar=>"b3ad324a454d7b507e34650f24f59493",
:timestamp=>time.to_i * 1000
}
# Sends a message to the server.
c[1].send(data.to_json)
# Receives a message from the server.
c[1].receive()
end
end
#p data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment