이제 며칠 동안 이벤트 머신을위한 비 - 에코 - 서버 예제를 찾았지만 아무 것도 보이지 않습니다. 의 내가 파일을 받아 들여 임시 파일에 기록합니다 서버 작성하고자한다고 가정 해 봅시다 :Ruby Eventmachine으로 파일을 작성하는 방법 (큰)
require 'rubygems'
require 'tempfile'
require 'eventmachine'
module ExampleServer
def receive_data(data)
f = Tempfile.new('random')
f.write(data)
ensure
f.close
end
end
EventMachine::run {
EventMachine::start_server "127.0.0.1", 8081, ExampleServer
puts 'running example server on 8081'
}
을 원자로를 차단하는 것 파일에 쓰기를,하지만 난 'Eventmachine 스타일'그것을 어떻게하지 않습니다. 데이터를 청크로 읽고 각 청크를 Em.next_tick 블록 내의 디스크에 기록해야합니까? 어떤 도움
감사 안드레아스
docs에서
Chris, 답변 해 주셔서 감사합니다. [이 답변] (http://stackoverflow.com/questions/2749503/what-is-the-best-way-to-read-files-in-an-eventmachine-based-app)에 의해 tmm1은 문서와 충돌합니다. 말 (또는 내가 오해 한 것). 기본적으로 나는 아주 간단한 파일 전송 (소켓에서 읽기 및 디스크에 쓰는 중 ...)을하려고합니다. – Andreas