Class: Bridge::Connection::SockBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/connection.rb

Instance Method Summary collapse

Constructor Details

#initializeSockBuffer

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