Class: FFWD::Debug::Connection

Inherits:
EM::Connection
  • Object
show all
Includes:
Logging
Defined in:
lib/ffwd/debug/connection.rb

Instance Method Summary collapse

Methods included from Logging

included, #log

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_peerObject



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_initObject



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

#unbindObject



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