Skip to content

Commit a135dbd

Browse files
authored
Merge pull request #8 from JordanOsterberg/master
Added localPeerId variable to MultipeerTranseiver
2 parents a32759c + 86b66ec commit a135dbd

File tree

11 files changed

+52
-29
lines changed

11 files changed

+52
-29
lines changed

Documentation/MultipeerConfiguration/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ <h3>
13511351

13521352
<footer>
13531353
<p>
1354-
Generated on <time datetime="2020-04-26T10:31:16-0300">26 April 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
1354+
Generated on <time datetime="2020-05-13T15:25:40-0700">May 13, 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
13551355
</p>
13561356
</footer>
13571357
</body>

Documentation/MultipeerConfiguration_Invitation/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ <h3>
12591259

12601260
<footer>
12611261
<p>
1262-
Generated on <time datetime="2020-04-26T10:31:16-0300">26 April 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
1262+
Generated on <time datetime="2020-05-13T15:25:40-0700">May 13, 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
12631263
</p>
12641264
</footer>
12651265
</body>

Documentation/MultipeerConfiguration_Security/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ <h3>
13041304

13051305
<footer>
13061306
<p>
1307-
Generated on <time datetime="2020-04-26T10:31:16-0300">26 April 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
1307+
Generated on <time datetime="2020-05-13T15:25:40-0700">May 13, 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
13081308
</p>
13091309
</footer>
13101310
</body>

Documentation/MultipeerDataSource/index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,28 +1215,27 @@ <h2 hidden>Relationships</h2>
12151215
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
12161216
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
12171217
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
1218-
<!-- Generated by graphviz version 2.42.3 (20191010.1750)
1218+
<!-- Generated by graphviz version 2.44.0 (20200408.0750)
12191219
-->
1220-
<!-- Title: %3 Pages: 1 -->
1220+
<!-- Pages: 1 -->
12211221
<svg width="872pt" height="116pt"
12221222
viewBox="0.00 0.00 872.00 116.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
12231223
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 112)">
1224-
<title>%3</title>
12251224
<polygon fill="white" stroke="transparent" points="-4,4 -4,-112 868,-112 868,4 -4,4"/>
12261225
<!-- MultipeerDataSource -->
12271226
<g id="node1" class="node class current">
12281227
<title>MultipeerDataSource</title>
12291228
<g id="a_node1"><a xlink:href="/MultipeerDataSource" xlink:title="MultipeerDataSource">
12301229
<path fill="none" stroke="black" stroke-width="3" d="M528,-108C528,-108 336,-108 336,-108 330,-108 324,-102 324,-96 324,-96 324,-84 324,-84 324,-78 330,-72 336,-72 336,-72 528,-72 528,-72 534,-72 540,-78 540,-84 540,-84 540,-96 540,-96 540,-102 534,-108 528,-108"/>
1231-
<text text-anchor="middle" x="432" y="-86.95" font-family="Menlo" font-size="14.00">MultipeerDataSource</text>
1230+
<text text-anchor="middle" x="432" y="-86.3" font-family="Menlo" font-size="14.00">MultipeerDataSource</text>
12321231
</a>
12331232
</g>
12341233
</g>
12351234
<!-- ObservableObject -->
12361235
<g id="node2" class="node unknown">
12371236
<title>ObservableObject</title>
12381237
<path fill="none" stroke="black" d="M528,-36C528,-36 336,-36 336,-36 330,-36 324,-30 324,-24 324,-24 324,-12 324,-12 324,-6 330,0 336,0 336,0 528,0 528,0 534,0 540,-6 540,-12 540,-12 540,-24 540,-24 540,-30 534,-36 528,-36"/>
1239-
<text text-anchor="middle" x="432" y="-14.95" font-family="Menlo" font-size="14.00">ObservableObject</text>
1238+
<text text-anchor="middle" x="432" y="-14.3" font-family="Menlo" font-size="14.00">ObservableObject</text>
12401239
</g>
12411240
<!-- MultipeerDataSource&#45;&gt;ObservableObject -->
12421241
<g id="edge1" class="edge conformsTo">
@@ -1316,7 +1315,7 @@ <h3>
13161315

13171316
<footer>
13181317
<p>
1319-
Generated on <time datetime="2020-04-26T10:31:17-0300">26 April 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
1318+
Generated on <time datetime="2020-05-13T15:25:40-0700">May 13, 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
13201319
</p>
13211320
</footer>
13221321
</body>

Documentation/MultipeerTransceiver/index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@
11971197
<nav>
11981198
<div class="wrapper">
11991199
<h2>On This Page</h2>
1200-
<ol><li><a href="#initializers">Initializers</a><ul><li class="initializer"><a href="#multipeertransceiver.init(configuration:)">init(configuration:​)</a></li></ul></li><li><a href="#properties">Properties</a><ul><li class="property"><a href="#multipeertransceiver.availablepeersdidchange">available​Peers​Did​Change</a></li><li class="property"><a href="#multipeertransceiver.peeradded">peer​Added</a></li><li class="property"><a href="#multipeertransceiver.peerremoved">peer​Removed</a></li><li class="property"><a href="#multipeertransceiver.availablepeers">available​Peers</a></li></ul></li><li><a href="#methods">Methods</a><ul><li class="method"><a href="#multipeertransceiver.receive(_:using:)">receive(_:​using:​)</a></li><li class="method"><a href="#multipeertransceiver.resume()">resume()</a></li><li class="method"><a href="#multipeertransceiver.stop()">stop()</a></li><li class="method"><a href="#multipeertransceiver.broadcast(_:)">broadcast(_:​)</a></li><li class="method"><a href="#multipeertransceiver.send(_:to:)">send(_:​to:​)</a></li><li class="method"><a href="#multipeertransceiver.invite(_:with:timeout:completion:)">invite(_:​with:​timeout:​completion:​)</a></li></ul></li></ol>
1200+
<ol><li><a href="#initializers">Initializers</a><ul><li class="initializer"><a href="#multipeertransceiver.init(configuration:)">init(configuration:​)</a></li></ul></li><li><a href="#properties">Properties</a><ul><li class="property"><a href="#multipeertransceiver.availablepeersdidchange">available​Peers​Did​Change</a></li><li class="property"><a href="#multipeertransceiver.peeradded">peer​Added</a></li><li class="property"><a href="#multipeertransceiver.peerremoved">peer​Removed</a></li><li class="property"><a href="#multipeertransceiver.localpeerid">local​Peer​Id</a></li><li class="property"><a href="#multipeertransceiver.availablepeers">available​Peers</a></li></ul></li><li><a href="#methods">Methods</a><ul><li class="method"><a href="#multipeertransceiver.receive(_:using:)">receive(_:​using:​)</a></li><li class="method"><a href="#multipeertransceiver.resume()">resume()</a></li><li class="method"><a href="#multipeertransceiver.stop()">stop()</a></li><li class="method"><a href="#multipeertransceiver.broadcast(_:)">broadcast(_:​)</a></li><li class="method"><a href="#multipeertransceiver.send(_:to:)">send(_:​to:​)</a></li><li class="method"><a href="#multipeertransceiver.invite(_:with:timeout:completion:)">invite(_:​with:​timeout:​completion:​)</a></li></ul></li></ol>
12011201
</div>
12021202
</nav>
12031203

@@ -1278,6 +1278,16 @@ <h3>
12781278
<div class="summary" role="doc-abstract">
12791279
<p>Called on the main queue when a peer removed.</p>
12801280

1281+
</div>
1282+
</div>
1283+
<div role="article" class="class" id="multipeertransceiver.localpeerid">
1284+
<h3>
1285+
<code>local​Peer​Id</code>
1286+
</h3>
1287+
<html><body><pre class="highlight"><code><span class="keyword">var</span> <span class="variable">localPeerId</span>: <span class="type">String</span>?</code></pre></body></html>
1288+
<div class="summary" role="doc-abstract">
1289+
<p>The current device's peer id</p>
1290+
12811291
</div>
12821292
</div>
12831293
<div role="article" class="class" id="multipeertransceiver.availablepeers">
@@ -1491,7 +1501,7 @@ <h4>Parameters</h4>
14911501

14921502
<footer>
14931503
<p>
1494-
Generated on <time datetime="2020-04-26T10:31:16-0300">26 April 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
1504+
Generated on <time datetime="2020-05-13T15:25:40-0700">May 13, 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
14951505
</p>
14961506
</footer>
14971507
</body>

Documentation/Peer/index.html

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,44 +1219,43 @@ <h2 hidden>Relationships</h2>
12191219
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
12201220
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
12211221
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
1222-
<!-- Generated by graphviz version 2.42.3 (20191010.1750)
1222+
<!-- Generated by graphviz version 2.44.0 (20200408.0750)
12231223
-->
1224-
<!-- Title: %3 Pages: 1 -->
1224+
<!-- Pages: 1 -->
12251225
<svg width="872pt" height="116pt"
12261226
viewBox="0.00 0.00 872.00 116.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
12271227
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 112)">
1228-
<title>%3</title>
12291228
<polygon fill="white" stroke="transparent" points="-4,4 -4,-112 868,-112 868,4 -4,4"/>
12301229
<!-- Peer -->
12311230
<g id="node1" class="node structure current">
12321231
<title>Peer</title>
12331232
<g id="a_node1"><a xlink:href="/Peer" xlink:title="Peer">
12341233
<path fill="none" stroke="black" stroke-width="3" d="M528,-108C528,-108 336,-108 336,-108 330,-108 324,-102 324,-96 324,-96 324,-84 324,-84 324,-78 330,-72 336,-72 336,-72 528,-72 528,-72 534,-72 540,-78 540,-84 540,-84 540,-96 540,-96 540,-102 534,-108 528,-108"/>
1235-
<text text-anchor="middle" x="432" y="-86.95" font-family="Menlo" font-size="14.00">Peer</text>
1234+
<text text-anchor="middle" x="432" y="-86.3" font-family="Menlo" font-size="14.00">Peer</text>
12361235
</a>
12371236
</g>
12381237
</g>
1239-
<!-- Hashable -->
1238+
<!-- Identifiable -->
12401239
<g id="node2" class="node unknown">
1241-
<title>Hashable</title>
1240+
<title>Identifiable</title>
12421241
<path fill="none" stroke="black" d="M303,-36C303,-36 111,-36 111,-36 105,-36 99,-30 99,-24 99,-24 99,-12 99,-12 99,-6 105,0 111,0 111,0 303,0 303,0 309,0 315,-6 315,-12 315,-12 315,-24 315,-24 315,-30 309,-36 303,-36"/>
1243-
<text text-anchor="middle" x="207" y="-14.95" font-family="Menlo" font-size="14.00">Hashable</text>
1242+
<text text-anchor="middle" x="207" y="-14.3" font-family="Menlo" font-size="14.00">Identifiable</text>
12441243
</g>
1245-
<!-- Peer&#45;&gt;Hashable -->
1246-
<g id="edge1" class="edge conformsTo">
1247-
<title>Peer&#45;&gt;Hashable</title>
1244+
<!-- Peer&#45;&gt;Identifiable -->
1245+
<g id="edge2" class="edge conformsTo">
1246+
<title>Peer&#45;&gt;Identifiable</title>
12481247
<path fill="none" stroke="black" d="M377.25,-71.97C345.4,-62.06 305.08,-49.51 271.67,-39.12"/>
12491248
<polygon fill="black" stroke="black" points="272.59,-35.74 262,-36.11 270.51,-42.42 272.59,-35.74"/>
12501249
</g>
1251-
<!-- Identifiable -->
1250+
<!-- Hashable -->
12521251
<g id="node3" class="node unknown">
1253-
<title>Identifiable</title>
1252+
<title>Hashable</title>
12541253
<path fill="none" stroke="black" d="M753,-36C753,-36 561,-36 561,-36 555,-36 549,-30 549,-24 549,-24 549,-12 549,-12 549,-6 555,0 561,0 561,0 753,0 753,0 759,0 765,-6 765,-12 765,-12 765,-24 765,-24 765,-30 759,-36 753,-36"/>
1255-
<text text-anchor="middle" x="657" y="-14.95" font-family="Menlo" font-size="14.00">Identifiable</text>
1254+
<text text-anchor="middle" x="657" y="-14.3" font-family="Menlo" font-size="14.00">Hashable</text>
12561255
</g>
1257-
<!-- Peer&#45;&gt;Identifiable -->
1258-
<g id="edge2" class="edge conformsTo">
1259-
<title>Peer&#45;&gt;Identifiable</title>
1256+
<!-- Peer&#45;&gt;Hashable -->
1257+
<g id="edge1" class="edge conformsTo">
1258+
<title>Peer&#45;&gt;Hashable</title>
12601259
<path fill="none" stroke="black" d="M486.75,-71.97C518.6,-62.06 558.92,-49.51 592.33,-39.12"/>
12611260
<polygon fill="black" stroke="black" points="593.49,-42.42 602,-36.11 591.41,-35.74 593.49,-42.42"/>
12621261
</g>
@@ -1324,7 +1323,7 @@ <h3>
13241323

13251324
<footer>
13261325
<p>
1327-
Generated on <time datetime="2020-04-26T10:31:17-0300">26 April 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
1326+
Generated on <time datetime="2020-05-13T15:25:40-0700">May 13, 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
13281327
</p>
13291328
</footer>
13301329
</body>

Documentation/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ <h2>Enumerations</h2>
12781278

12791279
<footer>
12801280
<p>
1281-
Generated on <time datetime="2020-04-26T10:31:16-0300">26 April 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
1281+
Generated on <time datetime="2020-05-13T15:25:40-0700">May 13, 2020</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a>.
12821282
</p>
12831283
</footer>
12841284
</body>

Sources/MultipeerKit/Internal API/MockMultipeerConnection.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,9 @@ final class MockMultipeerConnection: MultipeerProtocol {
2929
func invite(_ peer: Peer, with context: Data?, timeout: TimeInterval, completion: InvitationCompletionHandler?) {
3030

3131
}
32+
33+
func getLocalPeerId() -> String? {
34+
return "MockId"
35+
}
3236

3337
}

Sources/MultipeerKit/Internal API/MultipeerConnection.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ final class MultipeerConnection: NSObject, MultipeerProtocol {
106106

107107
browser.invitePeer(peer.underlyingPeer, to: session, withContext: context, timeout: timeout)
108108
}
109+
110+
func getLocalPeerId() -> String? {
111+
return try? Peer(peer: me, discoveryInfo: nil).id
112+
}
109113

110114
}
111115

Sources/MultipeerKit/Internal API/MultipeerProtocol.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ protocol MultipeerProtocol: AnyObject {
1616
func invite(_ peer: Peer, with context: Data?, timeout: TimeInterval, completion: InvitationCompletionHandler?)
1717
func broadcast(_ data: Data) throws
1818
func send(_ data: Data, to peers: [Peer]) throws
19+
20+
func getLocalPeerId() -> String?
1921

2022
}

0 commit comments

Comments
 (0)