Class: ActionCable::Connection::MessageBuffer
- Defined in:
- actioncable/lib/action_cable/connection/message_buffer.rb
Overview
Allows us to buffer messages received from the WebSocket before the Connection has been fully initialized, and is ready to receive them.
Instance Method Summary collapse
- #append(message) ⇒ Object
-
#initialize(connection) ⇒ MessageBuffer
constructor
A new instance of MessageBuffer.
- #process! ⇒ Object
- #processing? ⇒ Boolean
Constructor Details
#initialize(connection) ⇒ MessageBuffer
Returns a new instance of MessageBuffer.
7 8 9 10 |
# File 'actioncable/lib/action_cable/connection/message_buffer.rb', line 7 def initialize(connection) @connection = connection @buffered_messages = [] end |
Instance Method Details
#append(message) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'actioncable/lib/action_cable/connection/message_buffer.rb', line 12 def append() if valid? if processing? receive else buffer end else connection.logger.error "Couldn't handle non-string message: #{.class}" end end |
#process! ⇒ Object
28 29 30 31 |
# File 'actioncable/lib/action_cable/connection/message_buffer.rb', line 28 def process! @processing = true end |
#processing? ⇒ Boolean
24 25 26 |
# File 'actioncable/lib/action_cable/connection/message_buffer.rb', line 24 def processing? @processing end |