RevueSDK · Swift reference Guides

Instance Method

publish(message:to:timeout:)

發送訊息給指定參與者(Room 層訊息管道)

@discardableResult func publish(message: String, to participant: RemoteParticipant, timeout: TimeInterval = 10) async throws -> UInt32

Parameters

message

訊息文字

participant

接收方 RemoteParticipant

timeout

等待 delivery receipt 的最長秒數。範圍 5~30 秒,預設 10 秒; 超出範圍不報錯、自動限制:大於 30 用 30,小於 5(含 0、負數)用 5; NaN 沒有大小可比,用預設的 10 秒 (限制由 FriendManager.sendMessage 套用)

Return Value

對方裝置 toxcore 回 ACK 時的 messageId

Discussion

和 FriendManager.sendMessage 的差異:

兩者底層共用 toxcore transport,但在 wire format 和 delegate 路由上完全隔離。

Throws

  • RoomMessageError.encodingFailed — JSON envelope 編碼失敗(罕見)

  • RoomMessageError.messageTooLong — envelope 超過 toxcore 1372 bytes 上限

  • RoomMessageError.transportFailed(underlying:) — 底層 FriendManager 失敗

  • CancellationError — Revue.destroy() 觸發