class Slack::RealTime::Client

def keep_alive?

Ensure the server is running, and ping the remote server if no other messages were sent.
def keep_alive?
  # We can't ping the remote server if we aren't connected.
  return false if @socket.nil? || !@socket.connected?
  time_since_last_message = @socket.time_since_last_message
  # If the server responded within the specified time, we are okay:
  return true if time_since_last_message < websocket_ping
  # If the server has not responded for a while:
  return false if time_since_last_message > (websocket_ping * 2)
  # Kick off the next ping message:
  ping
  true
end