Skip to content

Bugfix: unable to listen postgres changes on channel. #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
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
17 changes: 3 additions & 14 deletions Sources/Realtime/Channel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,10 @@ public class Channel {

/// Initialize a Channel
/// - parameter topic: Topic of the Channel
/// - parameter options: Optional. Options to configure channel broadcast and presence
/// - parameter options: Optional. Options to configure channel broadcast and presence. Leave nil for postgres channel.
/// - parameter socket: Socket that the channel is a part of
convenience init(topic: ChannelTopic, options: ChannelOptions = ChannelOptions(), socket: RealtimeClient) {
let params = [
"config": [
"presence": [
"key": options.presenceKey ?? ""
],
"broadcast": [
"ack": options.broadcastAcknowledge,
"self": options.broadcastSelf
]
]
]
self.init(topic: topic, params: params, socket: socket)
convenience init(topic: ChannelTopic, options: ChannelOptions? = nil, socket: RealtimeClient) {
self.init(topic: topic, params: options?.params ?? [:], socket: socket)
}

/// Initialize a Channel
Expand Down
16 changes: 16 additions & 0 deletions Sources/Realtime/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,22 @@ public struct ChannelOptions {
self.broadcastSelf = broadcastSelf
self.broadcastAcknowledge = broadcastAcknowledge
}

/// Parameters used to configure the channel
var params: [String: [String: Any]] {
[
"config": [
"presence": [
"key": presenceKey ?? ""
],
"broadcast": [
"ack": broadcastAcknowledge,
"self": broadcastSelf
]
]
]
}

}

/// Represents the different status of a push
Expand Down
4 changes: 2 additions & 2 deletions Sources/Realtime/RealtimeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,11 @@ public class RealtimeClient: TransportDelegate {
/// let channel = socket.channel("rooms", options: ChannelOptions(presenceKey: "user123"))
///
/// - parameter topic: Topic of the channel
/// - parameter options: Optional. Options for the channel
/// - parameter options: Optional. Options to configure channel broadcast and presence. Leave nil for postgres channel.
/// - return: A new channel
public func channel(
_ topic: ChannelTopic,
options: ChannelOptions = ChannelOptions()
options: ChannelOptions? = nil
) -> Channel {
let channel = Channel(topic: topic, options: options, socket: self)
channels.append(channel)
Expand Down