test/configs/simple.rb in fizx-proxymachine-1.7.1 vs test/configs/simple.rb in fizx-proxymachine-1.8.0
- old
+ new
@@ -2,11 +2,25 @@
callback = proc do |data|
data + ":callback"
end
-proxy do |data|
+class TestServerConnection < EventMachine::Connection
+ def self.request(host, port, callback)
+ EventMachine.connect(host, port, self, callback)
+ end
+
+ def initialize(callback)
+ @callback = callback
+ end
+
+ def receive_data(data)
+ @callback.call(data)
+ end
+end
+
+proxy do |data, conn|
if data == 'a'
{ :remote => "localhost:9980" }
elsif data == 'b'
{ :remote => "localhost:9981" }
elsif data == 'c'
@@ -23,9 +37,15 @@
{ :remote => "localhost:9980", :callback => callback }
elsif data == 'connect reject'
{ :remote => "localhost:9989" }
elsif data == 'inactivity'
{ :remote => "localhost:9980", :data => 'sleep 3', :inactivity_timeout => 1, :inactivity_warning_timeout => 0.5 }
+ elsif data == 'delayed'
+ sc = TestServerConnection.request("localhost", 9981, proc{
+ conn.establish_remote_server(:close => "ohai")
+ })
+ sc.send_data "delayed"
+ { :noop => true }
else
{ :close => true }
end
end