class Proxi::ConsoleReporter

This is a very basic console reporter to see what’s happening

Subscribe to connection events, and you will see output that looks like this

1. +++
1. < 91
2. +++
3. +++
2. < 91
3. < 91
1. > 4096
1. > 3422
1. ---

Each connection gets a unique incremental number assigned, followed by:

Public Class Methods

new() click to toggle source
# File lib/proxi/reporting.rb, line 28
def initialize
  @count = 0
  @mutex = Mutex.new
  @connections = {}
end

Public Instance Methods

data_in(conn, data) click to toggle source
# File lib/proxi/reporting.rb, line 44
def data_in(conn, data)
  puts "#{@connections[conn]}. < #{data.size}"
end
data_out(conn, data) click to toggle source
# File lib/proxi/reporting.rb, line 48
def data_out(conn, data)
  puts "#{@connections[conn]}. > #{data.size}"
end
end_connection(conn) click to toggle source
# File lib/proxi/reporting.rb, line 39
def end_connection(conn)
  puts "#{@connections[conn]}. ---"
  @connections.delete(conn)
end
main_loop_error(conn, exc) click to toggle source
# File lib/proxi/reporting.rb, line 52
def main_loop_error(conn, exc)
  STDERR.puts "#{@connections[conn]}. #{exc.class} #{exc.message}"
  STDERR.puts exc.backtrace
end
start_connection(conn) click to toggle source
# File lib/proxi/reporting.rb, line 34
def start_connection(conn)
  @mutex.synchronize { @connections[conn] = (@count += 1) }
  puts "#{@connections[conn]}. +++"
end