Skip to content

Commit

Permalink
extend ruby test client a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
welterde authored and quartzjer committed Aug 8, 2010
1 parent 234c395 commit 21e0a86
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions ruby/test_client.rb
@@ -1,18 +1,21 @@
require 'rubygems' require 'rubygems'
require 'eventmachine' require 'eventmachine'
require 'json'


module EchoServer module EchoServer
def post_init def post_init
puts "sending our hello" puts "sending our hello"
send_datagram "{'+end':'0eb2ad19a7b508cc09b2d52b4a506845db39fae2'}", "telehash.org", 42424 send_datagram({'+end'=>'0eb2ad19a7b508cc09b2d52b4a506845db39fae2'}.to_json, "telehash.org", 42424)
end end

def receive_data(data)
# parse message we received
telex=JSON.parse(data)
puts telex.inspect
end

end


def receive_data data EventMachine::run do
puts data EventMachine::open_datagram_socket "0.0.0.0", 0, EchoServer
end end

end

EventMachine::run {
EventMachine::open_datagram_socket "0.0.0.0", 0, EchoServer
}

0 comments on commit 21e0a86

Please sign in to comment.