Class: Baykit::BayServer::Docker::Terminal::HijackersShip

Inherits:
Common::ReadOnlyShip
  • Object
show all
Includes:
Agent, Http::H1, Http::H1::H1CommandHandler, Protocol, Util
Defined in:
lib/baykit/bayserver/docker/terminal/hijackers_ship.rb

Direct Known Subclasses

FullyHijackersShip

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHijackersShip

Returns a new instance of HijackersShip.



28
29
30
31
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 28

def initialize
  super
  reset()
end

Instance Attribute Details

#command_unpackerObject (readonly)

Returns the value of attribute command_unpacker.



26
27
28
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 26

def command_unpacker
  @command_unpacker
end

#file_wrote_lenObject (readonly)

Returns the value of attribute file_wrote_len.



22
23
24
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 22

def file_wrote_len
  @file_wrote_len
end

#packet_storeObject (readonly)

Returns the value of attribute packet_store.



24
25
26
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 24

def packet_store
  @packet_store
end

#packet_unpackerObject (readonly)

Returns the value of attribute packet_unpacker.



25
26
27
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 25

def packet_unpacker
  @packet_unpacker
end

#tourObject (readonly)

Returns the value of attribute tour.



19
20
21
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 19

def tour
  @tour
end

#tour_idObject (readonly)

Returns the value of attribute tour_id.



20
21
22
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 20

def tour_id
  @tour_id
end

Instance Method Details

#check_timeout(duration) ⇒ Object



101
102
103
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 101

def check_timeout(duration)
  BayLog.debug("%s Hijack timeout(Ignore)", self)
end

#init(tur, rd, tp) ⇒ Object

Init method



40
41
42
43
44
45
46
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 40

def init(tur, rd, tp)
  super(tur.ship.agent_id, rd, tp)

  @tour = tur
  @tour_id = tur.tour_id
  @file_wrote_len = 0
end

#notify_closeObject



97
98
99
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 97

def notify_close()
  BayLog.debug("%s Hijack Closed(Ignore)", self)
end

#notify_eofObject



86
87
88
89
90
91
92
93
94
95
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 86

def notify_eof()
  BayLog.debug "#{self} Hijack EOF"
  BayLog.debug("%s EOF", self)
  begin
    @tour.res.end_res_content(@tour_id)
  rescue IOError => e
    BayLog.debug_e(ex)
  end
  return NextSocketAction::CLOSE
end

#notify_error(e) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 77

def notify_error(e)
  BayLog.debug_e(e, "%s Hijack Error", self)
  begin
    @tour.res.send_error(@tour_id, HttpStatus::INTERNAL_SERVER_ERROR, nil, e)
  rescue IOError => ex
    BayLog.debug_e(ex)
  end
end

#notify_read(buf) ⇒ Object

implements Yacht



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 64

def notify_read(buf)
  @file_wrote_len += buf.length

  BayLog.debug "#{self} read hijack #{buf.length} bytes: total=#{@file_wrote_len}"

  available = @tour.res.send_res_content(@tour_id, buf, 0, buf.length)
  if !available
    return NextSocketAction::SUSPEND
  else
    return NextSocketAction::CONTINUE
  end
end

#resetObject

implements Reusable



53
54
55
56
57
58
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 53

def reset()
  @file_wrote_len = 0
  @file_len = 0
  @tour = nil
  @tour_id = 0
end

#to_sObject



33
34
35
# File 'lib/baykit/bayserver/docker/terminal/hijackers_ship.rb', line 33

def to_s()
  return "hijack##{@yacht_id}/#{@object_id} tour=#{@tour} id=#{@tour_id}";
end