From 48a77d55bb6fd8d267d9ad2561ad55e48b0ba98b Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Tue, 30 Sep 2025 16:29:49 -0300 Subject: [PATCH] feat: add support for broadcast replay configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added ReplayOption struct and replay field to BroadcastJoinConfig to support configuring broadcast replay with 'since' timestamp and optional 'limit' parameter. Broadcast callbacks will automatically receive meta field with replayed status and message id when replay is enabled. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- Sources/Realtime/RealtimeJoinConfig.swift | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Sources/Realtime/RealtimeJoinConfig.swift b/Sources/Realtime/RealtimeJoinConfig.swift index 3c5df1f38..38d39092f 100644 --- a/Sources/Realtime/RealtimeJoinConfig.swift +++ b/Sources/Realtime/RealtimeJoinConfig.swift @@ -33,6 +33,20 @@ struct RealtimeJoinConfig: Codable, Hashable { } } +/// Configuration for broadcast replay feature. +/// Allows replaying broadcast messages from a specific timestamp. +public struct ReplayOption: Codable, Hashable, Sendable { + /// Unix timestamp (in milliseconds) from which to start replaying messages + public var since: Int + /// Optional limit on the number of messages to replay + public var limit: Int? + + public init(since: Int, limit: Int? = nil) { + self.since = since + self.limit = limit + } +} + public struct BroadcastJoinConfig: Codable, Hashable, Sendable { /// Instructs server to acknowledge that broadcast message was received. public var acknowledgeBroadcasts: Bool = false @@ -40,10 +54,23 @@ public struct BroadcastJoinConfig: Codable, Hashable, Sendable { /// /// By default, broadcast messages are only sent to other clients. public var receiveOwnBroadcasts: Bool = false + /// Configures broadcast replay from a specific timestamp + public var replay: ReplayOption? + + public init( + acknowledgeBroadcasts: Bool = false, + receiveOwnBroadcasts: Bool = false, + replay: ReplayOption? = nil + ) { + self.acknowledgeBroadcasts = acknowledgeBroadcasts + self.receiveOwnBroadcasts = receiveOwnBroadcasts + self.replay = replay + } enum CodingKeys: String, CodingKey { case acknowledgeBroadcasts = "ack" case receiveOwnBroadcasts = "self" + case replay } }