Skip to content

Commit

Permalink
ReceivePresenceEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Sep 6, 2024
1 parent 7f5d8f2 commit d1e5990
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sources/PubNub/KMM/Wrappers/PubNubSubscriptionObjC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Foundation
@objc
public class PubNubSubscriptionObjC: NSObject {
let subscription: Subscription
let receivePresenceEvents: Bool

@objc public var onMessage: ((PubNubMessageObjC) -> Void)?
@objc public var onPresence: (([PubNubPresenceChangeObjC]) -> Void)?
Expand All @@ -22,8 +23,9 @@ public class PubNubSubscriptionObjC: NSObject {
@objc public var onFile: ((PubNubFileChangeEventObjC) -> Void)?

@objc
public init(entity: PubNubEntityRepresentableObjC) {
public init(entity: PubNubEntityRepresentableObjC, receivePresenceEvents: Bool) {
self.subscription = Subscription(entity: entity.entity)
self.receivePresenceEvents = receivePresenceEvents
}

@objc
Expand Down Expand Up @@ -80,7 +82,10 @@ public class PubNubSubscriptionObjC: NSObject {

@objc
public func append(subscription: PubNubSubscriptionObjC) -> PubNubSubscriptionSetObjC {
let underlyingSubscription = Subscription(entity: subscription.subscription.entity)
let underlyingSubscription = Subscription(
entity: subscription.subscription.entity,
options: receivePresenceEvents ? ReceivePresenceEvents() : .empty()
)

underlyingSubscription.onMessage = {
subscription.onMessage?(PubNubMessageObjC(message: $0))
Expand Down

0 comments on commit d1e5990

Please sign in to comment.