Class: FFWD::Debug::Connection
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- FFWD::Debug::Connection
- Includes:
- Logging
- Defined in:
- lib/ffwd/debug/connection.rb
Instance Method Summary collapse
- #get_peer ⇒ Object
-
#initialize(handler) ⇒ Connection
constructor
A new instance of Connection.
- #post_init ⇒ Object
- #send_line(line) ⇒ Object
- #unbind ⇒ Object
Methods included from Logging
Constructor Details
#initialize(handler) ⇒ Connection
Returns a new instance of Connection.
20 21 22 23 24 25 |
# File 'lib/ffwd/debug/connection.rb', line 20 def initialize handler @handler = handler @peer = nil @ip = nil @port = nil end |
Instance Method Details
#get_peer ⇒ Object
27 28 29 30 31 |
# File 'lib/ffwd/debug/connection.rb', line 27 def get_peer peer = get_peername port, ip = Socket.unpack_sockaddr_in(peer) return peer, ip, port end |
#post_init ⇒ Object
33 34 35 36 37 |
# File 'lib/ffwd/debug/connection.rb', line 33 def post_init @peer, @ip, @port = get_peer @handler.register_client @peer, self log.info "#{@ip}:#{@port}: Connect" end |
#send_line(line) ⇒ Object
44 45 46 |
# File 'lib/ffwd/debug/connection.rb', line 44 def send_line line send_data "#{line}\n" end |
#unbind ⇒ Object
39 40 41 42 |
# File 'lib/ffwd/debug/connection.rb', line 39 def unbind @handler.unregister_client @peer, self log.info "#{@ip}:#{@port}: Disconnect" end |