{"id":24805085,"url":"https://github.com/benrobinson16/mpckit","last_synced_at":"2025-03-25T08:10:57.345Z","repository":{"id":190383642,"uuid":"286310003","full_name":"benrobinson16/MPCKit","owner":"benrobinson16","description":"A simple wrapper for the MultipeerConnectivity framework provided by Apple.","archived":false,"fork":false,"pushed_at":"2020-08-10T16:18:52.000Z","size":21,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T07:16:45.104Z","etag":null,"topics":["lightweight","multipeer-connectivity","multipeerconnectivity","multipeerconnectivity-framework","swift","swift-library","swift-package","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benrobinson16.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-08-09T20:14:33.000Z","updated_at":"2022-01-08T20:41:15.000Z","dependencies_parsed_at":"2023-08-24T12:25:22.228Z","dependency_job_id":null,"html_url":"https://github.com/benrobinson16/MPCKit","commit_stats":null,"previous_names":["benrobinson16/mpckit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FMPCKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FMPCKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FMPCKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FMPCKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benrobinson16","download_url":"https://codeload.github.com/benrobinson16/MPCKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245423125,"owners_count":20612740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lightweight","multipeer-connectivity","multipeerconnectivity","multipeerconnectivity-framework","swift","swift-library","swift-package","wrapper"],"created_at":"2025-01-30T07:16:48.852Z","updated_at":"2025-03-25T08:10:57.325Z","avatar_url":"https://github.com/benrobinson16.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPCKit\n\nA simple wrapper for the MultipeerConnectivity framework provided by Apple.\n\n## Set up:\n\n1. Add `NSLocalNetworkUsageDescription` key to your `Info.plist` file (required on iOS 14+)\n2. Add `NSBonjourServices` key to your `Info.plist` file. Add two items to the array: `_your-service._tcp` and `_your-service._udp`\n3. Create a delegate conforming to `MPCManagerDelegate` protocol in order to receive updates from the `MPCManager`.\n4. Create an instance of class `MPCManager` in your app. Only one instance should be made.\n\n```swift\nimport MPCKit\n\n// Create the manager\nlet myManager = MPCManager()\nmyManager.delegate = self\n\n// To start and stop advertising...\nmyManager.start(.advertising)\nmyManager.stop(.advertising)\n\n// To start and stop browsing...\nmyManager.start(.browsing)\nmyManager.stop(.browsing)\n\n// To start and stop new connections...\nmyManager.start(.newConnections)\nmyManager.stop(.newConnections)\n\n// To start and stop all connections (including existing)...\nmyManager.start(.allConnections)\nmyManager.stop(.allConnections)\n```\n## The delegate:\n\nAll changes that occur in the MPCManager class are reported via the delegate. \n\n### There are six required methods:\n\n```swift\nfunc foundPeer(id: MCPeerID, discoveryInfo: [String : String]?)\n```\nNotifies the delegate that a peer has been found. If you wish to invite the peer, call `func invite(peer: MCPeerID)` on the manager object.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc lostPeer(id: MCPeerID)\n```\nNotifies the delegate that a peer is no longer available for connection.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc connectedToPeer(id: MCPeerID)\n```\nNotifies the delegate that a peer has been successfully connected to.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc disconnectedFromPeer(id: MCPeerID)\n```\nNotifies the delegate that a peer has disconnected from the session.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc receivedInvite(from peerID: MCPeerID, context: Data?, response: @escaping (Bool) -\u003e Void)\n```\nNotifies the delegate that an invite has been received. Call `response(true)` to accept or `response(false)` to decline.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc encounteredError(error: Error)\n```\nNotifies the delegate that an error has been encountered, providing an opportunity to present an error message to the user.\u003cbr\u003e\u003cbr\u003e\n\n### There are four optional methods:\n\nThe following methods are optional because although every use case will require at least one of these, most only require one.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc didReceive(data: Data, fromPeer id: MCPeerID)\n```\nNotifies the delegate that data has been received.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc didReceive(stream: InputStream, withName name: String, fromPeer id: MCPeerID)\n```\nNotifies the delegate that a stream has been received.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc didStartReceivingResource(withName resourceName: String, fromPeer id: MCPeerID, progress: Progress)\n```\nNotifies the delegate that resources are starting to be received.\u003cbr\u003e\u003cbr\u003e\n\n```swift\nfunc didFinishReceivingResource(withName resourceName: String, fromPeer id: MCPeerID, at localURL: URL?, withError error: Error?)\n```\nNotifies the delegate that resources have been delivered to the specified local URL.\u003cbr\u003e\u003cbr\u003e\n\n## License\n\nPlease see LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenrobinson16%2Fmpckit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenrobinson16%2Fmpckit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenrobinson16%2Fmpckit/lists"}