如何设计互动节目?

时间:2015-09-24 05:30:32

标签: ruby mongodb login interactive

我想设计一个交互式登录程序,这是工作流程:

def login(username, password)
    // 1. get login url

    // 2. check captcha
    has_captcha = check_captcha()

    // deal with captcha if necessary
    if has_captcha
       // 3. return captcha to client
       // 4. I should wait until user input the captcha
    end

    // 5. finally, post login
end

我的问题出在step 3 and step 4,我的方式是:

  1. server写信给验证码给mongodb并等待。
  2. client检查mongodb数据是否每5秒更新一次
  3. server还会每隔5秒检查一次mongodb,如果服务器找到mongodb已经被客户端更新,那么从mongodb获取客户端数据,继续登录。
  4. 但这不是那么优雅,我该如何轻松实现呢?

0 个答案:

没有答案