Class: Bridge::Connection::SockBuffer
- Inherits:
-
Object
- Object
- Bridge::Connection::SockBuffer
- Defined in:
- lib/connection.rb
Instance Method Summary collapse
-
#initialize ⇒ SockBuffer
constructor
A new instance of SockBuffer.
- #process_queue(sock, client_id) ⇒ Object
- #send(msg) ⇒ Object
Constructor Details
#initialize ⇒ SockBuffer
Returns a new instance of SockBuffer.
143 144 145 146 |
# File 'lib/connection.rb', line 143 def initialize # Buffer for preconnect messages @buffer = [] end |
Instance Method Details
#process_queue(sock, client_id) ⇒ Object
152 153 154 155 156 157 158 |
# File 'lib/connection.rb', line 152 def process_queue sock, client_id @buffer.each do |msg| # Replace null client ids with actual client_id after handshake sock.send( msg.gsub '"client",null', '"client","'+ client_id + '"' ) end @buffer = [] end |
#send(msg) ⇒ Object
148 149 150 |
# File 'lib/connection.rb', line 148 def send msg @buffer << msg end |