Skip to content

Commit 8083464

Browse files
grdsdevclaude
andauthored
feat: add support for broadcast replay configuration (#805)
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 <[email protected]>
1 parent a12da4f commit 8083464

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Sources/Realtime/RealtimeJoinConfig.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,44 @@ struct RealtimeJoinConfig: Codable, Hashable {
3333
}
3434
}
3535

36+
/// Configuration for broadcast replay feature.
37+
/// Allows replaying broadcast messages from a specific timestamp.
38+
public struct ReplayOption: Codable, Hashable, Sendable {
39+
/// Unix timestamp (in milliseconds) from which to start replaying messages
40+
public var since: Int
41+
/// Optional limit on the number of messages to replay
42+
public var limit: Int?
43+
44+
public init(since: Int, limit: Int? = nil) {
45+
self.since = since
46+
self.limit = limit
47+
}
48+
}
49+
3650
public struct BroadcastJoinConfig: Codable, Hashable, Sendable {
3751
/// Instructs server to acknowledge that broadcast message was received.
3852
public var acknowledgeBroadcasts: Bool = false
3953
/// Broadcast messages back to the sender.
4054
///
4155
/// By default, broadcast messages are only sent to other clients.
4256
public var receiveOwnBroadcasts: Bool = false
57+
/// Configures broadcast replay from a specific timestamp
58+
public var replay: ReplayOption?
59+
60+
public init(
61+
acknowledgeBroadcasts: Bool = false,
62+
receiveOwnBroadcasts: Bool = false,
63+
replay: ReplayOption? = nil
64+
) {
65+
self.acknowledgeBroadcasts = acknowledgeBroadcasts
66+
self.receiveOwnBroadcasts = receiveOwnBroadcasts
67+
self.replay = replay
68+
}
4369

4470
enum CodingKeys: String, CodingKey {
4571
case acknowledgeBroadcasts = "ack"
4672
case receiveOwnBroadcasts = "self"
73+
case replay
4774
}
4875
}
4976

0 commit comments

Comments
 (0)