Class: Microsandbox::AgentFrame

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#bodyString (readonly)

Returns raw CBOR body bytes (ASCII-8BIT).

Returns:

  • (String)

    raw CBOR body bytes (ASCII-8BIT)



12
13
14
# File 'lib/microsandbox/agent.rb', line 12

def body
  @body
end

#flagsInteger (readonly)

Returns flag bits (see Microsandbox::AgentClient::FLAG_TERMINAL etc.).

Returns:



10
11
12
# File 'lib/microsandbox/agent.rb', line 10

def flags
  @flags
end

#idInteger (readonly)

Returns correlation id from the frame header.

Returns:

  • (Integer)

    correlation id from the frame header



8
9
10
# File 'lib/microsandbox/agent.rb', line 8

def id
  @id
end

Instance Method Details

#inspectObject



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.

Returns:

  • (Boolean)

    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.

Returns:

  • (Boolean)

    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.

Returns:

  • (Boolean)

    last frame of a stream



21
# File 'lib/microsandbox/agent.rb', line 21

def terminal? = (@flags & AgentClient::FLAG_TERMINAL) != 0