Permalink
Browse files

extend ruby test client a bit

  • Loading branch information...
1 parent 234c395 commit 21e0a86f8f23675a8aa1cb8522917093ba77c490 @welterde welterde committed with May 29, 2010
Showing with 17 additions and 14 deletions.
  1. +17 −14 ruby/test_client.rb
View
@@ -1,18 +1,21 @@
require 'rubygems'
require 'eventmachine'
+require 'json'
- module EchoServer
- def post_init
- puts "sending our hello"
- send_datagram "{'+end':'0eb2ad19a7b508cc09b2d52b4a506845db39fae2'}", "telehash.org", 42424
- end
+module EchoServer
+ def post_init
+ puts "sending our hello"
+ send_datagram({'+end'=>'0eb2ad19a7b508cc09b2d52b4a506845db39fae2'}.to_json, "telehash.org", 42424)
+ end
+
+ def receive_data(data)
+ # parse message we received
+ telex=JSON.parse(data)
+ puts telex.inspect
+ end
+
+end
- def receive_data data
- puts data
- end
-
- end
-
- EventMachine::run {
- EventMachine::open_datagram_socket "0.0.0.0", 0, EchoServer
- }
+EventMachine::run do
+ EventMachine::open_datagram_socket "0.0.0.0", 0, EchoServer
+end

0 comments on commit 21e0a86

Please sign in to comment.