-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(listeners): adding the new Listeners API feat(subscribe & presence): enabling EventEngine by default
- Loading branch information
1 parent
649a9e9
commit d5c5083
Showing
36 changed files
with
2,662 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Pod::Spec.new do |s| | ||
s.name = 'PubNubSwift' | ||
s.version = '6.3.0' | ||
s.version = '7.0.0' | ||
s.homepage = 'https://github.com/pubnub/swift' | ||
s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk' | ||
s.authors = { 'PubNub, Inc.' => '[email protected]' } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// PubNub+Subscribable.swift | ||
// | ||
// Copyright (c) PubNub Inc. | ||
// All rights reserved. | ||
// | ||
// This source code is licensed under the license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Protocol for types capable of creating references for entities to which the user can subscribe, | ||
/// receiving real-time updates. | ||
public protocol EntityCreator { | ||
/// Creates a new channel entity the user can subscribe to. | ||
/// | ||
/// This method does not create any entity, either locally or remotely; it merely provides | ||
/// a reference to a channel that can be subscribed to and unsubscribed from | ||
/// | ||
/// - Parameters: | ||
/// - name: The unique identifier for the channel. | ||
/// - Returns: A `ChannelRepresentation` object representing the channel. | ||
func channel(_ name: String) -> ChannelRepresentation | ||
|
||
/// Creates a new channel group entity the user can subscribe to. | ||
/// | ||
/// - Parameters: | ||
/// - name: The unique identifier for the channel group. | ||
/// - Returns: A `ChannelGroupRepresentation` object representing the channel group. | ||
func channelGroup(_ name: String) -> ChannelGroupRepresentation | ||
|
||
/// Creates user metadata entity the user can subscribe to. | ||
/// | ||
/// This method does not create any entity, either locally or remotely; it merely provides | ||
/// a reference to a channel that can be subscribed to and unsubscribed from | ||
/// | ||
/// - Parameters: | ||
/// - name: The unique identifier for the user metadata. | ||
/// - Returns: A `UserMetadataRepresentation` object representing the user metadata. | ||
func userMetadata(_ name: String) -> UserMetadataRepresentation | ||
|
||
/// Creates channel metadata entity the user can subscribe to. | ||
/// | ||
/// This method does not create any entity, either locally or remotely; it merely provides | ||
/// a reference to a channel that can be subscribed to and unsubscribed from | ||
/// | ||
/// - Parameters: | ||
/// - name: The unique identifier for the channel metadata. | ||
/// - Returns: A `ChannelMetadataRepresentation` object representing the channel metadata. | ||
func channelMetadata(_ name: String) -> ChannelMetadataRepresentation | ||
} | ||
|
||
public extension EntityCreator { | ||
/// Creates a `SubscriptionSet` object from the collection of `Subscribable` entites. | ||
/// | ||
/// Use this function to set up and manage subscriptions for a collection of `Subscribable` entities. | ||
/// | ||
/// - Parameters: | ||
/// - queue: The dispatch queue on which the subscription events should be handled | ||
/// - entities: A collection of `Subscribable` entities to subscribe to | ||
/// - options: Additional options for configuring the subscription | ||
/// - Returns: A `SubscriptionSet` instance for managing the specified entities. | ||
func subscription( | ||
queue: DispatchQueue = .main, | ||
entities: any Collection<Subscribable>, | ||
options: SubscriptionOptions = SubscriptionOptions.empty() | ||
) -> SubscriptionSet { | ||
SubscriptionSet( | ||
queue: queue, | ||
entities: entities, | ||
options: options | ||
) | ||
} | ||
} | ||
|
||
// This internal protocol is designed for types capable of receiving an intent | ||
// to Subscribe or Unsubscribe and invoking the PubNub service with computed channels | ||
// and channel groups. | ||
protocol SubscribeReceiver: AnyObject { | ||
func registerAdapter(_ adapter: BaseSubscriptionListenerAdapter) | ||
func hasRegisteredAdapter(with uuid: UUID) -> Bool | ||
|
||
func internalSubscribe( | ||
with channels: [Subscription], | ||
and groups: [Subscription], | ||
at timetoken: Timetoken? | ||
) | ||
func internalUnsubscribe( | ||
from channels: [Subscription], | ||
and groups: [Subscription], | ||
presenceOnly: Bool | ||
) | ||
} |
47 changes: 47 additions & 0 deletions
47
Sources/PubNub/Events/New/Entities/EntitySubscribable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// EntitySubscribable.swift | ||
// | ||
// Copyright (c) PubNub Inc. | ||
// All rights reserved. | ||
// | ||
// This source code is licensed under the license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - PubNubChannelRepresentation | ||
|
||
/// Represents a channel that can be subscribed to and unsubscribed from using the PubNub service. | ||
public class ChannelRepresentation: Subscribable { | ||
init(name: String, receiver: SubscribeReceiver) { | ||
super.init(name: name, subscriptionType: .channel, receiver: receiver) | ||
} | ||
} | ||
|
||
// MARK: - PubNubChannelGroupRepresentation | ||
|
||
/// Represents a channel group that can be subscribed to and unsubscribed from using the PubNub service. | ||
public class ChannelGroupRepresentation: Subscribable { | ||
init(name: String, receiver: SubscribeReceiver) { | ||
super.init(name: name, subscriptionType: .channelGroup, receiver: receiver) | ||
} | ||
} | ||
|
||
// MARK: - PubNubUserMetadataRepresentation | ||
|
||
/// Represents user metadata that can be subscribed to and unsubscribed from using the PubNub service. | ||
public class UserMetadataRepresentation: Subscribable { | ||
init(id: String, receiver: SubscribeReceiver) { | ||
super.init(name: id, subscriptionType: .channel, receiver: receiver) | ||
} | ||
} | ||
|
||
// MARK: - PubNubChannelMetadataRepresentation | ||
|
||
/// Represents channel metadata that can be subscribed to and unsubscribed from using the PubNub service. | ||
public class ChannelMetadataRepresentation: Subscribable { | ||
init(id: String, receiver: SubscribeReceiver) { | ||
super.init(name: id, subscriptionType: .channel, receiver: receiver) | ||
} | ||
} |
Oops, something went wrong.