跳转到正文

packets API ​

完整接口目录 · 协议包用法 · 工具包下载

模块说明 ​

text
Task-owned packet listeners. Payloads remain tagged custom bytes or JSON bytes.

Packets ​

python
class Packets

Packets.__init__ ​

python
def __init__(self, context)

Packets.typed ​

python
@property
def typed(self)

SDK 说明:

text
Versioned protocol models and connection-fenced generic packet APIs.

Packets.catalog ​

python
async def catalog(self)

SDK 说明:

text
Static version-scoped metadata, unchanged; unknown is not permission.

Encoding registration and conditional transport never prove server
acceptance. Legacy observable describes the observation adapter only.

Packets.prepare_raw ​

python
def prepare_raw(self, frame, *, connection_id, idempotency_key, deadline)

SDK 说明:

text
Prepare an immutable raw send intent; persist it before send_raw.

Packets.send_raw ​

python
async def send_raw(self, intent, *, timeout=10)

SDK 说明:

text
Submit one prepared raw intent. Unknown results must not be replayed.

Packets.describe ​

python
async def describe(self, packet_id)

SDK 说明:

text
Registered forms and audit metadata; never reads the world.

Requires Host API minor 3. New metadata is additive: older Hosts may
omit it. Missing/unknown direction or execution must remain unknown.

Packets.preview ​

python
async def preview(
    self,
    packet_id,
    packet,
    *,
    format = 'original_json',
    packet_type = None,
    context = 'offline',
)

SDK 说明:

text
Encode a diagnostic body without sending or submitting an operation.

Requires Host API minor 3 and packet_preview_ids. HeldItemRef requires
context='inventory_snapshot' plus self-inventory observe permission.
OK means encoding succeeded, never server acceptance. Body uses shield
ID zero and omits the header: submit the original intent for live sends.

Packets.encode ​

python
async def encode(
    self,
    packet_id,
    packet,
    *,
    packet_type = None,
    format = 'lossless',
    context = 'offline',
)

SDK 说明:

text
Encode a lossless object to a headerless offline body, without sending.

Requires Host API minor 3 and packet_preview_ids. The Host uses the same
encoder as preview and caps the body at 128 KiB. Returns diagnostics
unchanged; OK only means encoding succeeded.

Packets.decode ​

python
async def decode(
    self,
    packet_id,
    body,
    *,
    packet_type = None,
    format = 'lossless',
    context = 'offline',
)

SDK 说明:

text
Decode complete headerless bytes into a lossless object, without sending.

Accepts bytes, bytearray or memoryview, up to 128 KiB. Requires Host API
minor 3 and packet_preview_ids. Uses offline shield ID zero; live frames
must not be passed here. Returns the Host's diagnostic result unchanged.

Packets.open ​

python
async def open(self, packet_ids, *, text_profile=None)

Packets.listen ​

python
async def listen(self, packet_ids, callback, *, on_snapshot=None, text_profile=None)

SDK 说明:

text
Open before returning; callback backpressure is serial, never task-per-packet.

Returns a Worker-owned asyncio Task. cancel() then await it to release.
Overflow/revocation fails the listener; never silently reconnect or replay.

Packets.context ​

python
self.context

公开实例属性,在 __init__ 中设置。

Neomega · 使用、开发与参考文档