Method: Isaac::Queue#transmit

Defined in:
lib/isaac.rb

#transmitObject

To prevent excess flood no more than 1472 bytes will be sent to the server. When that limit is reached, @lock = true and the server will be PINGed. @lock will be true until a PONG is received (Application#handle).



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/isaac.rb', line 227

def transmit
  Thread.start { loop {
    unless @lock || @queue.empty?
      msg = @queue.first
      if (@transfered + msg.size) > 1472
        # No honestly, :excess. The RFC is not too clear on this subject TODO
        @socket.puts "PING :excess"
        @lock = true
        @transfered = 0
      else
        @socket.puts msg
        @transfered += msg.size
        @queue.shift
      end
    end
    sleep 0.1
  }}
end