Skip to content

Instantly share code, notes, and snippets.

@pochi
Created May 6, 2012 17:09
Show Gist options
  • Save pochi/2623334 to your computer and use it in GitHub Desktop.
Save pochi/2623334 to your computer and use it in GitHub Desktop.
# coding: utf-8
require "eventmachine"
require "em-http"
clients = 120
HOST = "localhost"
PORT = 4567
class Client < EM::Connection
attr_accessor :client_id
def initialize(args)
super
@client_id = args[:client_id].to_s
end
def post_init
EM::HttpRequest.new("http://localhost:4567/login.json?id=#{client_id}").get
EM.add_periodic_timer(1) do
EM::HttpRequest.new("http://localhost:4567/update.json?id=#{client_id}").get
end
end
end
EM.run do
clients.times do |i|
EM::connect(HOST, PORT, Client, :client_id => i)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment