Class: MailRoom::IMAP
- Inherits:
-
Net::IMAP
- Object
- Net::IMAP
- MailRoom::IMAP
- Defined in:
- lib/mail_room/backports/imap.rb
Instance Method Summary collapse
-
#idle(timeout = nil, &response_handler) ⇒ Object
Backported 2.3.0 version of net/imap idle command to support timeout.
Instance Method Details
#idle(timeout = nil, &response_handler) ⇒ Object
Backported 2.3.0 version of net/imap idle command to support timeout
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mail_room/backports/imap.rb', line 4 def idle(timeout = nil, &response_handler) raise LocalJumpError, "no block given" unless response_handler response = nil synchronize do tag = Thread.current[:net_imap_tag] = generate_tag put_string("#{tag} IDLE#{CRLF}") begin add_response_handler(response_handler) @idle_done_cond = new_cond @idle_done_cond.wait(timeout) @idle_done_cond = nil if @receiver_thread_terminating raise Net::IMAP::Error, "connection closed" end ensure unless @receiver_thread_terminating remove_response_handler(response_handler) put_string("DONE#{CRLF}") response = get_tagged_response(tag, "IDLE") end end end return response end |