net/imap idle

Discussion in 'Ruby' started by Payton Swick, Jan 5, 2006.

  1. Payton Swick

    Payton Swick Guest

    Perhaps there's another way to do this without polling, but I added the
    IMAP IDLE (and associated DONE) command to Shugo Maeda's excellent
    net/imap API.

    For those unaware, RFC 2177 adds the IDLE command to the IMAP
    specification which allows the server to notify clients when a mailbox
    has changed state (particularly when new mail has arrived).

    When issued, an IDLE command requires a DONE to complete it, which
    should be issued at least every 29 minutes, to prevent a timeout.

    Anyway, here's the (tiny) piece of code I wrote to implement this; I
    hope it's useful. Feel free to tell me what I did wrong.

    class Net::IMAP
    def idle
    cmd = "IDLE"
    synchronize do
    tag = generate_tag
    put_string(tag + " " + cmd)
    put_string(CRLF)
    end
    end
    def done
    cmd = "DONE"
    synchronize do
    put_string(cmd)
    put_string(CRLF)
    end
    end
    end

    -Payton
    Payton Swick, Jan 5, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henrik Ormåsen

    Curier-IMAP and imap.create()

    Henrik Ormåsen, Aug 19, 2006, in forum: Ruby
    Replies:
    0
    Views:
    175
    Henrik Ormåsen
    Aug 19, 2006
  2. Jon Fi
    Replies:
    4
    Views:
    521
    Kashia Buch
    Oct 21, 2006
  3. jasonnaylor
    Replies:
    1
    Views:
    247
    jasonnaylor
    Apr 16, 2008
  4. Abhishiv Saxena

    Support for IMAP IDLE in net/imap

    Abhishiv Saxena, Jul 3, 2009, in forum: Ruby
    Replies:
    4
    Views:
    190
    Eric Hodel
    Jul 4, 2009
  5. Abhishiv Saxena

    Support for IMAP IDLE in net/imap

    Abhishiv Saxena, Jul 3, 2009, in forum: Ruby
    Replies:
    0
    Views:
    229
    Abhishiv Saxena
    Jul 3, 2009
Loading...

Share This Page