Ruby 如何检查EventMachine::Connection是否打开?
我在事件机中有一个连接对象的句柄: 如何检查连接在任何时间点是否打开或关闭?Ruby 如何检查EventMachine::Connection是否打开?,ruby,eventmachine,Ruby,Eventmachine,我在事件机中有一个连接对象的句柄: 如何检查连接在任何时间点是否打开或关闭? 我没有看到API中指定的任何方法。您必须自己实现它,这非常简单 class SampleConnection < EM::Connection attr_accessor :connected def connection_completed connected = true end def connected? !!connected end def unbind
我没有看到API中指定的任何方法。您必须自己实现它,这非常简单
class SampleConnection < EM::Connection
attr_accessor :connected
def connection_completed
connected = true
end
def connected?
!!connected
end
def unbind
connected = false
end
end
class SampleConnection
是的,自己实现很容易。我想再次检查一下,课堂上没有现成的解决方案。