【发布时间】:2012-06-22 04:23:32
【问题描述】:
我在事件机器中有一个 Connection 对象的句柄:http://eventmachine.rubyforge.org/EventMachine/Connection.html
如何检查连接在任何时间点是打开还是关闭? 我没有看到 API 中指定的任何方法。
【问题讨论】:
标签: ruby eventmachine
我在事件机器中有一个 Connection 对象的句柄:http://eventmachine.rubyforge.org/EventMachine/Connection.html
如何检查连接在任何时间点是打开还是关闭? 我没有看到 API 中指定的任何方法。
【问题讨论】:
标签: ruby eventmachine
你必须自己实现它,这很容易。
class SampleConnection < EM::Connection
attr_accessor :connected
def connection_completed
connected = true
end
def connected?
!!connected
end
def unbind
connected = false
end
end
【讨论】: