-
-
Save tmm1/21424 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
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 | |
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
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