Skip to content
New issue

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

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

Already on GitHub? # to your account

exposing setPeerName explicitly #28

Merged
merged 1 commit into from
Apr 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ public actor PeerToPeerProvider: NetworkProvider {
var delegate: (any NetworkEventReceiver)?
var peerId: PEER_ID? // this providers peer Id
var peerMetadata: PeerMetadata? // this providers peer metadata
public var peerName: String {
didSet {
self.resetName(peerName)
}
}

public var peerName: String

// the human-readable name to advertise on Bonjour alongside peerId

Expand Down Expand Up @@ -241,7 +238,7 @@ public actor PeerToPeerProvider: NetworkProvider {
if config.listening {
if peerName.isEmpty {
let defaultName = await PeerToPeerProviderConfiguration.defaultSharingIdentity()
resetName(defaultName)
setName(defaultName)
}
}
}
Expand Down Expand Up @@ -269,7 +266,7 @@ public actor PeerToPeerProvider: NetworkProvider {

public func startListening(as peerName: String? = nil) async throws {
if let peerName {
resetName(peerName)
setName(peerName)
}
if self.peerName.isEmpty {
throw Errors.NetworkProviderError(msg: "No peer name is set on the provider")
Expand Down Expand Up @@ -784,7 +781,7 @@ public actor PeerToPeerProvider: NetworkProvider {
}

// Update the advertised name on the network.
fileprivate func resetName(_ name: String) {
public func setName(_ name: String) {
self.peerName = name
txtRecord[TXTRecordKeys.name] = name

Expand Down
Loading