Skip to content

Commit 1cc6563

Browse files
committed
Changed access modifiers and regen jazzy docs
1 parent e70dfe2 commit 1cc6563

File tree

30 files changed

+143
-1692
lines changed

30 files changed

+143
-1692
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ all:
22

33
docs:
44
rm -rf docs
5-
jazzy --config .jazzy.yml --min-acl internal
5+
jazzy --config .jazzy.yml
66
cp -r Assets docs/

MultiPeer.xcodeproj/project.pbxproj

Lines changed: 0 additions & 419 deletions
Large diffs are not rendered by default.

Sources/MultiPeer.swift

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,46 @@ import Foundation
99
import MultipeerConnectivity
1010

1111
// MARK: - Main Class
12-
class MultiPeer: NSObject {
12+
public class MultiPeer: NSObject {
1313

14-
static let instance = MultiPeer()
14+
public static let instance = MultiPeer()
1515

1616
// MARK: Properties
1717

1818
/** Conforms to MultiPeerDelegate: Handles receiving data and changes in connections */
1919
weak var delegate: MultiPeerDelegate?
2020

2121
/** Name of MultiPeer session: Up to one hyphen (-) and 15 characters */
22-
var serviceType: String!
22+
public var serviceType: String!
2323

2424
/** Device's name */
25-
var devicePeerID: MCPeerID!
25+
public var devicePeerID: MCPeerID!
2626

2727
/** Advertises session */
28-
var serviceAdvertiser: MCNearbyServiceAdvertiser!
28+
public var serviceAdvertiser: MCNearbyServiceAdvertiser!
2929

3030
/** Browses for sessions */
31-
var serviceBrowser: MCNearbyServiceBrowser!
31+
public var serviceBrowser: MCNearbyServiceBrowser!
3232

3333
/** Amount of time to spend connecting before timeout */
34-
var connectionTimeout = 10.0
34+
public var connectionTimeout = 10.0
3535

3636
/** Peers available to connect to */
37-
var availablePeers: [Peer] = []
37+
public var availablePeers: [Peer] = []
3838

3939
/** Peers connected to */
40-
var connectedPeers: [Peer] = []
40+
public var connectedPeers: [Peer] = []
4141

4242
/** Names of all connected devices */
43-
var connectedDeviceNames: [String] {
43+
public var connectedDeviceNames: [String] {
4444
return session.connectedPeers.map({$0.displayName})
4545
}
4646

4747
/** Prints out all errors and status updates */
48-
var debugMode = false
48+
public var debugMode = false
4949

5050
/** Main session object that manages the current connections */
51-
lazy var session: MCSession = {
51+
public lazy var session: MCSession = {
5252
let session = MCSession(peer: self.devicePeerID, securityIdentity: nil, encryptionPreference: .none)
5353
session.delegate = self
5454
return session
@@ -60,7 +60,7 @@ class MultiPeer: NSObject {
6060
/// - Parameters:
6161
/// - serviceType: String with name of MultiPeer service. Up to one hyphen (-) and 15 characters.
6262
/// Uses default device name
63-
func initialize(serviceType: String) {
63+
public func initialize(serviceType: String) {
6464
#if os(iOS)
6565
initialize(serviceType: serviceType, deviceName: UIDevice.current.name)
6666
#elseif os(macOS)
@@ -72,7 +72,7 @@ class MultiPeer: NSObject {
7272
/// - Parameters:
7373
/// - serviceType: String with name of MultiPeer service. Up to one hyphen (-) and 15 characters.
7474
/// - deviceName: String containing custom name for device
75-
func initialize(serviceType: String, deviceName: String) {
75+
public func initialize(serviceType: String, deviceName: String) {
7676
// Setup device/session properties
7777
self.serviceType = serviceType
7878
self.devicePeerID = MCPeerID(displayName: deviceName)
@@ -97,51 +97,51 @@ class MultiPeer: NSObject {
9797
// MARK: - Methods
9898

9999
/** HOST: Automatically browses and invites all found devices */
100-
func startInviting() {
100+
public func startInviting() {
101101
self.serviceBrowser.startBrowsingForPeers()
102102
}
103103

104104
/** JOIN: Automatically advertises and accepts all invites */
105-
func startAccepting() {
105+
public func startAccepting() {
106106
self.serviceAdvertiser.startAdvertisingPeer()
107107
}
108108

109109
/** HOST and JOIN: Uses both advertising and browsing to connect. */
110-
func autoConnect() {
110+
public func autoConnect() {
111111
startInviting()
112112
startAccepting()
113113
}
114114

115115
/** Stops the invitation process */
116-
func stopInviting() {
116+
public func stopInviting() {
117117
self.serviceBrowser.stopBrowsingForPeers()
118118
}
119119

120120
/** Stops accepting invites and becomes invisible on the network */
121-
func stopAccepting() {
121+
public func stopAccepting() {
122122
self.serviceAdvertiser.stopAdvertisingPeer()
123123
}
124124

125125
/** Stops all invite/accept services */
126-
func stopSearching() {
126+
public func stopSearching() {
127127
stopAccepting()
128128
stopInviting()
129129
}
130130

131131
/** Disconnects from the current session and stops all searching activity */
132-
func disconnect() {
132+
public func disconnect() {
133133
session.disconnect()
134134
connectedPeers.removeAll()
135135
availablePeers.removeAll()
136136
}
137137

138138
/** Stops all invite/accept services, disconnects from the current session, and stops all searching activity */
139-
func end() {
139+
public func end() {
140140
stopSearching()
141141
disconnect()
142142
}
143143

144-
var isConnected: Bool {
144+
public var isConnected: Bool {
145145
return connectedPeers.count > 0
146146
}
147147

@@ -150,7 +150,7 @@ class MultiPeer: NSObject {
150150
/// - object: Object (Any) to send to all connected peers.
151151
/// - type: Type of data (UInt32) sent
152152
/// After sending the object, you can use the extension for Data, `convertData()` to convert it back into an object.
153-
func send(object: Any, type: UInt32) {
153+
public func send(object: Any, type: UInt32) {
154154
if isConnected {
155155
let data = NSKeyedArchiver.archivedData(withRootObject: object)
156156

@@ -163,7 +163,7 @@ class MultiPeer: NSObject {
163163
/// - data: Data (Data) to send to all connected peers.
164164
/// - type: Type of data (UInt32) sent
165165
/// After sending the data, you can use the extension for Data, `convertData()` to convert it back into data.
166-
func send(data: Data, type: UInt32) {
166+
public func send(data: Data, type: UInt32) {
167167
if isConnected {
168168
do {
169169
let container: [Any] = [data, type]
@@ -188,15 +188,15 @@ class MultiPeer: NSObject {
188188
extension MultiPeer: MCNearbyServiceAdvertiserDelegate {
189189

190190
// Received invitation
191-
func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: Data?, invitationHandler: @escaping (Bool, MCSession?) -> Void) {
191+
public func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: Data?, invitationHandler: @escaping (Bool, MCSession?) -> Void) {
192192

193193
OperationQueue.main.addOperation {
194194
invitationHandler(true, self.session)
195195
}
196196
}
197197

198198
// Error, could not start advertising
199-
func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didNotStartAdvertisingPeer error: Error) {
199+
public func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didNotStartAdvertisingPeer error: Error) {
200200
printDebug("Could not start advertising due to error: \(error)")
201201
}
202202

@@ -206,7 +206,7 @@ extension MultiPeer: MCNearbyServiceAdvertiserDelegate {
206206
extension MultiPeer: MCNearbyServiceBrowserDelegate {
207207

208208
// Found a peer
209-
func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String: String]?) {
209+
public func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String: String]?) {
210210
printDebug("Found peer: \(peerID)")
211211

212212
// Update the list and the controller
@@ -216,15 +216,15 @@ extension MultiPeer: MCNearbyServiceBrowserDelegate {
216216
}
217217

218218
// Lost a peer
219-
func browser(_ browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID) {
219+
public func browser(_ browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID) {
220220
printDebug("Lost peer: \(peerID)")
221221

222222
// Update the lost peer
223223
availablePeers = availablePeers.filter { $0.peerID != peerID }
224224
}
225225

226226
// Error, could not start browsing
227-
func browser(_ browser: MCNearbyServiceBrowser, didNotStartBrowsingForPeers error: Error) {
227+
public func browser(_ browser: MCNearbyServiceBrowser, didNotStartBrowsingForPeers error: Error) {
228228
printDebug("Could not start browsing due to error: \(error)")
229229
}
230230

@@ -234,7 +234,7 @@ extension MultiPeer: MCNearbyServiceBrowserDelegate {
234234
extension MultiPeer: MCSessionDelegate {
235235

236236
// Peer changed state
237-
func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {
237+
public func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {
238238
// If the new state is connected, then remove it from the available peers
239239
// Otherwise, update the state
240240
if state == .connected {
@@ -255,7 +255,7 @@ extension MultiPeer: MCSessionDelegate {
255255
}
256256

257257
// Received data
258-
func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {
258+
public func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {
259259
printDebug("Received data: \(data.count) bytes")
260260

261261
guard let container = data.convert() as? [Any] else { return }
@@ -269,17 +269,17 @@ extension MultiPeer: MCSessionDelegate {
269269
}
270270

271271
// Received stream
272-
func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID) {
272+
public func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID) {
273273
printDebug("Received stream")
274274
}
275275

276276
// Started receiving resource
277-
func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {
277+
public func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {
278278
printDebug("Started receiving resource with name: \(resourceName)")
279279
}
280280

281281
// Finished receiving resource
282-
func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL?, withError error: Error?) {
282+
public func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL?, withError error: Error?) {
283283
printDebug("Finished receiving resource with name: \(resourceName)")
284284
}
285285

@@ -289,12 +289,12 @@ extension MultiPeer: MCSessionDelegate {
289289
extension Data {
290290

291291
/** Unarchive data into an object. It will be returned as type `Any`. */
292-
func convert() -> Any {
292+
public func convert() -> Any {
293293
return NSKeyedUnarchiver.unarchiveObject(with: self)!
294294
}
295295

296296
/** Converts an object into Data using NSKeyedArchiver */
297-
static func toData(object: Any) -> Data {
297+
public static func toData(object: Any) -> Data {
298298
return NSKeyedArchiver.archivedData(withRootObject: object)
299299
}
300300

Sources/Peer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
import MultipeerConnectivity
1010

1111
// Contains the peerID and state presented to tableview
12-
class Peer {
12+
public class Peer {
1313

1414
var peerID: MCPeerID
1515
var state: MCSessionState

Tests/MultiPeerTests.swift

Lines changed: 0 additions & 21 deletions
This file was deleted.

Tests/Supporting Files/Info-iOS.plist

Lines changed: 0 additions & 22 deletions
This file was deleted.

Tests/Supporting Files/Info-macOS.plist

Lines changed: 0 additions & 22 deletions
This file was deleted.

docs/Classes.html

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<a title="Classes Reference"></a>
1414
<header>
1515
<div class="content-wrapper">
16-
<p><a href="index.html">MultiPeer Docs</a> (55% documented)</p>
16+
<p><a href="index.html">MultiPeer Docs</a> (58% documented)</p>
1717
<p class="header-right"><a href="https://github.com/dingwilson/MultiPeer"><img src="img/gh.png"/>View on GitHub</a></p>
1818
</div>
1919
</header>
@@ -34,7 +34,7 @@
3434
<a href="Classes/MultiPeer.html">MultiPeer</a>
3535
</li>
3636
<li class="nav-group-task">
37-
<a href="Classes/Peer.html">Peer</a>
37+
<a href="Classes.html#/s:9MultiPeer0B0C">Peer</a>
3838
</li>
3939
</ul>
4040
</li>
@@ -46,14 +46,6 @@
4646
</li>
4747
</ul>
4848
</li>
49-
<li class="nav-group-name">
50-
<a href="Protocols.html">Protocols</a>
51-
<ul class="nav-group-tasks">
52-
<li class="nav-group-task">
53-
<a href="Protocols/MultiPeerDelegate.html">MultiPeerDelegate</a>
54-
</li>
55-
</ul>
56-
</li>
5749
</ul>
5850
</nav>
5951
<article class="main-content">
@@ -81,13 +73,12 @@ <h1>Classes</h1>
8173
<div class="abstract">
8274
<p>Undocumented</p>
8375

84-
<a href="Classes/Peer.html" class="slightly-smaller">See more</a>
8576
</div>
8677
<div class="declaration">
8778
<h4>Declaration</h4>
8879
<div class="language">
8980
<p class="aside-title">Swift</p>
90-
<pre class="highlight swift"><code><span class="kd">class</span> <span class="kt">Peer</span></code></pre>
81+
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Peer</span></code></pre>
9182

9283
</div>
9384
</div>
@@ -126,7 +117,7 @@ <h3 class="section-name">Main Class</h3>
126117
<h4>Declaration</h4>
127118
<div class="language">
128119
<p class="aside-title">Swift</p>
129-
<pre class="highlight swift"><code><span class="kd">class</span> <span class="kt">MultiPeer</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>
120+
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">MultiPeer</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>
130121

131122
</div>
132123
</div>

0 commit comments

Comments
 (0)