Skip to content

Instantly share code, notes, and snippets.

@tmm1
Forked from bmizerany/client.rb
Created October 31, 2008 21:21
Show Gist options
  • Save tmm1/21424 to your computer and use it in GitHub Desktop.
Save tmm1/21424 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'eventmachine'
module TapsClient
def connection_completed
p [Time.now, :connected]
send_data("hey!")
end
def receive_data(data)
p [Time.now, :data, data]
STDOUT.flush
end
def unbind
p [Time.now, :disconnected]
end
end
EventMachine.run do
EM.connect 'localhost', 5678, TapsClient
end
require 'rubygems'
require 'eventmachine'
module TapsServer
def post_init
p [Time.now, :connected]
end
def recieve_data(data)
p [Time.now, :data, data]
send_data(data)
end
def unbind
p [Time.now, :disconnected]
end
end
EM.run do
EM.start_server 'localhost', 5678, TapsServer
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment