class ActionCable::Connection::MessageBuffer

:nodoc:
Allows us to buffer messages received from the WebSocket before the Connection has been fully initialized, and is ready to receive them.

def append(message)

def append(message)
  if valid? message
    if processing?
      receive message
    else
      buffer message
    end
  else
    connection.logger.error "Couldn't handle non-string message: #{message.class}"
  end
end

def buffer(message)

def buffer(message)
  buffered_messages << message
end

def initialize(connection)

:nodoc:
Allows us to buffer messages received from the WebSocket before the Connection has been fully initialized, and is ready to receive them.
def initialize(connection)
  @connection = connection
  @buffered_messages = []
end

def process!

def process!
  @processing = true
  receive_buffered_messages
end

def processing?

def processing?
  @processing
end

def receive(message)

def receive(message)
  connection.receive message
end

def receive_buffered_messages

def receive_buffered_messages
  receive buffered_messages.shift until buffered_messages.empty?
end

def valid?(message)

def valid?(message)
  message.is_a?(String)
end