Class: Gt06Server::Session
- Inherits:
-
Object
- Object
- Gt06Server::Session
- Defined in:
- lib/gt06_server/session.rb
Defined Under Namespace
Classes: SessionError
Instance Attribute Summary collapse
-
#addr ⇒ Object
readonly
Returns the value of attribute addr.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
-
#terminal_id ⇒ Object
readonly
Returns the value of attribute terminal_id.
Instance Method Summary collapse
-
#initialize(socket, logger: Logger.new(STDOUT)) ⇒ Session
constructor
A new instance of Session.
- #inspect ⇒ Object
- #run {|Hash| ... } ⇒ Object
Constructor Details
#initialize(socket, logger: Logger.new(STDOUT)) ⇒ Session
Returns a new instance of Session.
11 12 13 14 15 16 17 18 19 |
# File 'lib/gt06_server/session.rb', line 11 def initialize(socket, logger: Logger.new(STDOUT)) @socket = socket @addr = socket.peeraddr @terminal_id = '' @info = { received_count: 0, sent_count: 0, last_received_at: Time.now } @logger = logger logger.debug 'New session has been created' end |
Instance Attribute Details
#addr ⇒ Object (readonly)
Returns the value of attribute addr.
7 8 9 |
# File 'lib/gt06_server/session.rb', line 7 def addr @addr end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
7 8 9 |
# File 'lib/gt06_server/session.rb', line 7 def info @info end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/gt06_server/session.rb', line 7 def logger @logger end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
7 8 9 |
# File 'lib/gt06_server/session.rb', line 7 def socket @socket end |
#terminal_id ⇒ Object (readonly)
Returns the value of attribute terminal_id.
7 8 9 |
# File 'lib/gt06_server/session.rb', line 7 def terminal_id @terminal_id end |
Instance Method Details
#inspect ⇒ Object
31 32 33 |
# File 'lib/gt06_server/session.rb', line 31 def inspect "#{object_id} Terminal id:#{@terminal_id}, ip: #{@addr}, #{@info}" end |