Skip to content

Commit

Permalink
Prevent memory leaks when passing token getters (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoavGro authored Oct 6, 2023
1 parent 783e7a2 commit 2628c8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/SwiftCentrifuge/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum CentrifugeError: Error {
case replyError(code: UInt32, message: String, temporary: Bool)
}

public protocol CentrifugeConnectionTokenGetter {
public protocol CentrifugeConnectionTokenGetter: NSObject {
func getConnectionToken(_ event: CentrifugeConnectionTokenEvent, completion: @escaping (Result<String, Error>) -> ())
}

Expand Down Expand Up @@ -56,7 +56,7 @@ public struct CentrifugeClientConfig {
public var name = "swift"
public var version = ""
public var token: String = ""
public var tokenGetter: CentrifugeConnectionTokenGetter?
public weak var tokenGetter: CentrifugeConnectionTokenGetter?
public var data: Data? = nil
public var debug: Bool = false
public var logger: CentrifugeLogger?
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftCentrifuge/Subscription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public protocol CentrifugeSubscriptionTokenGetter {
public protocol CentrifugeSubscriptionTokenGetter: NSObject {
func getSubscriptionToken(_ event: CentrifugeSubscriptionTokenEvent, completion: @escaping (Result<String, Error>) -> ())
}

Expand All @@ -33,7 +33,7 @@ public struct CentrifugeSubscriptionConfig {
public var positioned: Bool = false
public var recoverable: Bool = false
public var joinLeave: Bool = false
public var tokenGetter: CentrifugeSubscriptionTokenGetter?
public weak var tokenGetter: CentrifugeSubscriptionTokenGetter?
}

public enum CentrifugeSubscriptionState {
Expand Down

0 comments on commit 2628c8c

Please sign in to comment.