diff --git a/Documentation/MultipeerConfiguration/index.html b/Documentation/MultipeerConfiguration/index.html index 5fa9d9d..b27382d 100755 --- a/Documentation/MultipeerConfiguration/index.html +++ b/Documentation/MultipeerConfiguration/index.html @@ -1351,7 +1351,7 @@

diff --git a/Documentation/MultipeerConfiguration_Invitation/index.html b/Documentation/MultipeerConfiguration_Invitation/index.html index 5cedb97..c333c92 100755 --- a/Documentation/MultipeerConfiguration_Invitation/index.html +++ b/Documentation/MultipeerConfiguration_Invitation/index.html @@ -1259,7 +1259,7 @@

diff --git a/Documentation/MultipeerConfiguration_Security/index.html b/Documentation/MultipeerConfiguration_Security/index.html index 064ff67..eb3445a 100755 --- a/Documentation/MultipeerConfiguration_Security/index.html +++ b/Documentation/MultipeerConfiguration_Security/index.html @@ -1304,7 +1304,7 @@

diff --git a/Documentation/MultipeerDataSource/index.html b/Documentation/MultipeerDataSource/index.html index 462b504..36c6795 100755 --- a/Documentation/MultipeerDataSource/index.html +++ b/Documentation/MultipeerDataSource/index.html @@ -1215,20 +1215,19 @@

- - + -%3 MultipeerDataSource -MultipeerDataSource +MultipeerDataSource @@ -1236,7 +1235,7 @@ ObservableObject -ObservableObject +ObservableObject @@ -1316,7 +1315,7 @@

- Generated on using swift-doc. + Generated on using swift-doc.

diff --git a/Documentation/MultipeerTransceiver/index.html b/Documentation/MultipeerTransceiver/index.html index 50bf9b1..70dc691 100755 --- a/Documentation/MultipeerTransceiver/index.html +++ b/Documentation/MultipeerTransceiver/index.html @@ -1197,7 +1197,7 @@ @@ -1278,6 +1278,16 @@

Called on the main queue when a peer removed.

+
+ +
+

+ local​Peer​Id +

+
var localPeerId: String?
+
+

The current device's peer id

+
@@ -1491,7 +1501,7 @@

Parameters

- Generated on using swift-doc. + Generated on using swift-doc.

diff --git a/Documentation/Peer/index.html b/Documentation/Peer/index.html index e62befe..177e385 100755 --- a/Documentation/Peer/index.html +++ b/Documentation/Peer/index.html @@ -1219,44 +1219,43 @@ - - + -%3 Peer -Peer +Peer - + -Hashable +Identifiable -Hashable +Identifiable - - -Peer->Hashable + + +Peer->Identifiable - + -Identifiable +Hashable -Identifiable +Hashable - - -Peer->Identifiable + + +Peer->Hashable @@ -1324,7 +1323,7 @@

- Generated on using swift-doc. + Generated on using swift-doc.

diff --git a/Documentation/index.html b/Documentation/index.html index 95a3918..ece4a00 100755 --- a/Documentation/index.html +++ b/Documentation/index.html @@ -1278,7 +1278,7 @@

Enumerations

diff --git a/Sources/MultipeerKit/Internal API/MockMultipeerConnection.swift b/Sources/MultipeerKit/Internal API/MockMultipeerConnection.swift index 5d383b3..f6e257b 100644 --- a/Sources/MultipeerKit/Internal API/MockMultipeerConnection.swift +++ b/Sources/MultipeerKit/Internal API/MockMultipeerConnection.swift @@ -29,5 +29,9 @@ final class MockMultipeerConnection: MultipeerProtocol { func invite(_ peer: Peer, with context: Data?, timeout: TimeInterval, completion: InvitationCompletionHandler?) { } + + func getLocalPeerId() -> String? { + return "MockId" + } } diff --git a/Sources/MultipeerKit/Internal API/MultipeerConnection.swift b/Sources/MultipeerKit/Internal API/MultipeerConnection.swift index 2936723..0ed0bfe 100644 --- a/Sources/MultipeerKit/Internal API/MultipeerConnection.swift +++ b/Sources/MultipeerKit/Internal API/MultipeerConnection.swift @@ -106,6 +106,10 @@ final class MultipeerConnection: NSObject, MultipeerProtocol { browser.invitePeer(peer.underlyingPeer, to: session, withContext: context, timeout: timeout) } + + func getLocalPeerId() -> String? { + return try? Peer(peer: me, discoveryInfo: nil).id + } } diff --git a/Sources/MultipeerKit/Internal API/MultipeerProtocol.swift b/Sources/MultipeerKit/Internal API/MultipeerProtocol.swift index 4fa33bc..cab54b9 100644 --- a/Sources/MultipeerKit/Internal API/MultipeerProtocol.swift +++ b/Sources/MultipeerKit/Internal API/MultipeerProtocol.swift @@ -16,5 +16,7 @@ protocol MultipeerProtocol: AnyObject { func invite(_ peer: Peer, with context: Data?, timeout: TimeInterval, completion: InvitationCompletionHandler?) func broadcast(_ data: Data) throws func send(_ data: Data, to peers: [Peer]) throws + + func getLocalPeerId() -> String? } diff --git a/Sources/MultipeerKit/Public API/MultipeerTransceiver.swift b/Sources/MultipeerKit/Public API/MultipeerTransceiver.swift index ede036a..2b0828d 100644 --- a/Sources/MultipeerKit/Public API/MultipeerTransceiver.swift +++ b/Sources/MultipeerKit/Public API/MultipeerTransceiver.swift @@ -18,6 +18,11 @@ public final class MultipeerTransceiver { /// Called on the main queue when a peer removed. public var peerRemoved: (Peer) -> Void = { _ in } + /// The current device's peer id + public var localPeerId: String? { + return connection.getLocalPeerId() + } + /// All peers currently available for invitation, connection and data transmission. public private(set) var availablePeers: [Peer] = [] { didSet {