require 'eventmachine'
module EchoServer
def post_init
puts "-- someone connected to the echo server!"
end
def receive_data data
send_data ">>>you sent: #{data}"
close_connection if data =~ /quit/i
end
def unbind
puts "-- someone disconnected from the echo server!"
end
end
class Test
attr_reader :some_value
def start
EventMachine::run {
EventMachine::start_server "127.0.0.1", 8081, EchoServer
}
end
end
我的问题是如何在 EchoServer 模块中获取 some_value ?类 Test 和模块 EchoServer 之间的关系是什么?