Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module EventMachine
- module RequestRouter
- module Backend
- attr_accessor :plexer, :data, :name, :port, :host, :debug
- def initialize(options)
- @debug = options[:debug] || false
- @name = options[:name] || :unknown
- debug [:initialize, @name]
- @host = options[:host] || "localhost"
- @port = options[:port] || 80
- @plexer = options[:plexer] || nil
- @data = []
- end
- def connection_completed
- debug [:backend_connection_completed, @name]
- end
- def post_init
- debug [:backend_post_init]
- rescue
- p $!
- puts $!.backtrace.join("\n ")
- exit!
- end
- def receive_data(data)
- debug [:backend_receive_data, @name, data]
- unless @plexer.nil?
- @plexer.relay_from_backend(data, @name)
- self.close_connection_after_writing()
- end
- end
- def send(data)
- debug [:send, @name]
- self.send_data(data)
- end
- def unbind
- debug [:backend_unbind, @name]
- end
- def debug(*data)
- return unless @debug
- require 'pp'
- pp data
- puts
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement