Created
November 4, 2010 19:01
-
-
Save lucky/662973 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Why did I ever write this? | |
require 'rubygems' | |
require 'eventmachine' | |
module MyClient | |
def receive_data data | |
puts "Got back: #{data}" | |
end | |
def unbind | |
puts "terminated connection" | |
end | |
end | |
EM.run { | |
EM.epoll | |
Signal.trap("INT") { EM.stop } | |
client = EM.connect "0.0.0.0", 10000, MyClient | |
EM.add_timer(2) { puts "a"; client.send_data Marshal.dump({:a => 1}) } | |
EM.add_timer(2) { puts "b"; client.send_data Marshal.dump({:b => 2}) } | |
EM.add_timer(2.1) { puts "c"; client.send_data Marshal.dump({:c => 3}) } | |
} | |
puts "END END END" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment