Class: Net::IMAP
- Inherits:
-
Object
- Object
- Net::IMAP
- Defined in:
- lib/net/imap/idle.rb
Instance Method Summary collapse
-
#idle(&response_handler) ⇒ Object
Sends an IDLE command that waits for notifications of new or expunged messages.
Instance Method Details
#idle(&response_handler) ⇒ Object
Sends an IDLE command that waits for notifications of new or expunged messages. Yields responses from the server during the IDLE.
Use break
in the response handler to leave IDLE.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/net/imap/idle.rb', line 11 def idle(&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}" add_response_handler response_handler begin response = get_tagged_response tag rescue LocalJumpError # can't break cross-threads or something ensure unless response then put_string "DONE#{CRLF}" response = get_tagged_response tag end remove_response_handler response_handler end end response end |