发送
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.
live outbound and inbound 通道 directional views
Syntax:
Category#
endpoint
Related#
Examples#
radix/corpus/ad/sermo-live-directional.fab (canonical · method)#
live outbound and inbound 通道 directional views
# =============================================================================
# 发送 — live outbound and inbound 通道 directional views.
# =============================================================================
#
# What this teaches:
# • Directional 通道 views — `发送<T>` for outbound frames, `接收<T>` for
# inbound frames on a 通道 connection
# • Cursor iteration — `遍历 取自 t.cursor()` consumes inbound frames
# • Accipe reception — `accipe()` pulls a single 帧 from the inbound
# 队列
#
# Common mistakes:
# • confusing `发送` (outbound) and `接收` (inbound) 通道 directional views, or mixing accipe/cursor/exhauri without intentional ordered consumption
#
# See also: 调用, 通道, 接收, 帧, 迭代器, accipe
# =============================================================================
# Live `发送<T>` / `接收<T>` directional views
#
# runtime:echo returns one inbound 文本 frame per conversation.
# accipe, 迭代器, and exhauri may share one 接收 队列; mix them only when
# ordered consumption is intentional.
main {
const 通道 s ← call 'runtime:echo' ("salve")
const 发送<string> m ← s.meus<string>()
m.da("ping")
const status outbound ← m.fini()
const 接收<string> t ← s.tuus<string>()
for from t.cursor() const frame {
assert frame.data ≡ "salve"
}
const status inbound ← t.fini()
const 通道 s2 ← call 'runtime:echo' ("salve")
const 接收<string> t2 ← s2.tuus<string>()
const 帧<string> ∪ none got ← t2.accipe()
const status accipe_done ← t2.fini()
print outbound
print inbound
print got
print accipe_done
}