Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Sources/Realtime/RealtimeJoinConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,44 @@ 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
/// Broadcast messages back to the sender.
///
/// 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
}
}

Expand Down
Loading