Class: Microsandbox::AgentFrame
- Inherits:
-
Object
- Object
- Microsandbox::AgentFrame
- Defined in:
- lib/microsandbox/agent.rb
Overview
A single raw agent-protocol frame: a correlation id, flag bits, and a CBOR-encoded body. Decode #body with a CBOR library of your choice.
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
Raw CBOR body bytes (ASCII-8BIT).
-
#flags ⇒ Integer
readonly
Flag bits (see Microsandbox::AgentClient::FLAG_TERMINAL etc.).
-
#id ⇒ Integer
readonly
Correlation id from the frame header.
Instance Method Summary collapse
-
#initialize(data) ⇒ AgentFrame
constructor
A new instance of AgentFrame.
- #inspect ⇒ Object
-
#session_start? ⇒ Boolean
Opens a new session.
-
#shutdown? ⇒ Boolean
Connection-shutdown signal.
-
#terminal? ⇒ Boolean
Last frame of a stream.
Constructor Details
#initialize(data) ⇒ AgentFrame
Returns a new instance of AgentFrame.
14 15 16 17 18 |
# File 'lib/microsandbox/agent.rb', line 14 def initialize(data) @id = data["id"] @flags = data["flags"] @body = data["body"] end |
Instance Attribute Details
#body ⇒ String (readonly)
Returns raw CBOR body bytes (ASCII-8BIT).
12 13 14 |
# File 'lib/microsandbox/agent.rb', line 12 def body @body end |
#flags ⇒ Integer (readonly)
Returns flag bits (see Microsandbox::AgentClient::FLAG_TERMINAL etc.).
10 11 12 |
# File 'lib/microsandbox/agent.rb', line 10 def flags @flags end |
#id ⇒ Integer (readonly)
Returns correlation id from the frame header.
8 9 10 |
# File 'lib/microsandbox/agent.rb', line 8 def id @id end |
Instance Method Details
#inspect ⇒ Object
29 30 31 |
# File 'lib/microsandbox/agent.rb', line 29 def inspect "#<Microsandbox::AgentFrame id=#{@id} flags=0x#{@flags.to_s(16)} body=#{@body&.bytesize}B>" end |
#session_start? ⇒ Boolean
Returns opens a new session.
24 |
# File 'lib/microsandbox/agent.rb', line 24 def session_start? = (@flags & AgentClient::FLAG_SESSION_START) != 0 |
#shutdown? ⇒ Boolean
Returns connection-shutdown signal.
27 |
# File 'lib/microsandbox/agent.rb', line 27 def shutdown? = (@flags & AgentClient::FLAG_SHUTDOWN) != 0 |
#terminal? ⇒ Boolean
Returns last frame of a stream.
21 |
# File 'lib/microsandbox/agent.rb', line 21 def terminal? = (@flags & AgentClient::FLAG_TERMINAL) != 0 |