Class: Baykit::BayServer::Docker::Base::InboundDataListener

Inherits:
Object
  • Object
show all
Includes:
Agent, Agent::Transporter::DataListener
Defined in:
lib/baykit/bayserver/docker/base/inbound_data_listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sip) ⇒ InboundDataListener

Returns a new instance of InboundDataListener.



16
17
18
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 16

def initialize(sip)
  @ship = sip
end

Instance Attribute Details

#shipObject (readonly)

Returns the value of attribute ship.



14
15
16
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 14

def ship
  @ship
end

Instance Method Details

#check_timeout(duration_sec) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 70

def check_timeout(duration_sec)
  if @ship.socket_timeout_sec <= 0
    timeout = false;
  elsif @ship.keeping
    timeout = duration_sec >= BayServer.harbor.keep_timeout_sec
  else
    timeout = duration_sec >= @ship.socket_timeout_sec
  end
  BayLog.debug("%s Check timeout: dur=%d timeout=%s, keeping=%s, limit=%d",
               self, duration_sec, timeout, @ship.keeping, @ship.socket_timeout_sec)
  return timeout
end

#notify_closeObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 55

def notify_close
  BayLog.debug("%s notify_close", self)

  @ship.abort_tours()

  if !@ship.active_tours.empty?
    # cannot close because there are some running tours
    BayLog.debug("%s cannot end ship because there are some running tours (ignore)", self)
    @ship.need_end = true
  else
    @ship.end_ship()
  end

end

#notify_connectObject

Implements DataListener

Raises:



28
29
30
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 28

def notify_connect()
  raise Sink.new()
end

#notify_eofObject



42
43
44
45
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 42

def notify_eof()
  BayLog.trace("%s notify_eof", self)
  return NextSocketAction::CLOSE
end

#notify_handshake_done(protocol) ⇒ Object



32
33
34
35
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 32

def notify_handshake_done(protocol)
  BayLog.trace("%s notify_handshake_done: proto=%s", self, protocol)
  return NextSocketAction::CONTINUE
end

#notify_protocol_error(err) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 47

def notify_protocol_error(err)
  BayLog.trace("%s notify_protocol_error", self)
  if BayLog.debug_mode?
    BayLog.error_e(err)
  end
  return @ship.protocol_handler.on_protocol_error(err)
end

#notify_read(buf, adr) ⇒ Object



37
38
39
40
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 37

def notify_read(buf, adr)
  BayLog.trace("%s notify_read", self)
  return @ship.protocol_handler.bytes_received(buf)
end

#to_sObject



20
21
22
# File 'lib/baykit/bayserver/docker/base/inbound_data_listener.rb', line 20

def to_s
  return @ship.to_s
end