{"id":1199,"url":"https://github.com/rchatham/PeerConnectivity","last_synced_at":"2025-07-30T20:32:46.554Z","repository":{"id":62450589,"uuid":"60809028","full_name":"rchatham/PeerConnectivity","owner":"rchatham","description":"Functional wrapper for Apple's MultipeerConnectivity framework.","archived":false,"fork":false,"pushed_at":"2023-12-16T22:34:53.000Z","size":2693,"stargazers_count":56,"open_issues_count":4,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-03T12:12:47.369Z","etag":null,"topics":[],"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/rchatham.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"roadmap":null,"authors":null}},"created_at":"2016-06-09T21:42:22.000Z","updated_at":"2024-10-25T02:47:35.000Z","dependencies_parsed_at":"2024-01-26T21:16:55.290Z","dependency_job_id":null,"html_url":"https://github.com/rchatham/PeerConnectivity","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rchatham%2FPeerConnectivity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rchatham%2FPeerConnectivity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rchatham%2FPeerConnectivity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rchatham%2FPeerConnectivity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rchatham","download_url":"https://codeload.github.com/rchatham/PeerConnectivity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187558,"owners_count":17882325,"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":[],"created_at":"2024-01-05T20:15:41.089Z","updated_at":"2024-12-04T20:31:04.802Z","avatar_url":"https://github.com/rchatham.png","language":"Swift","funding_links":[],"categories":["Hardware"],"sub_categories":["Bluetooth","Other free courses"],"readme":"\n![PeerConnectivity](http://reidchatham.com/src/PeerConnectivity.png)\n\n\n[![Platform: iOS 8+](https://img.shields.io/badge/platform-iOS%208%2B-blue.svg?style=flat)]()\n[![Language: Swift 3](https://img.shields.io/badge/language-swift3-f48041.svg?style=flat)](https://developer.apple.com/swift)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Cocoapods compatible](https://cocoapod-badges.herokuapp.com/v/PeerConnectivity/badge.png)](https://cocoapods.org/pods/PeerConnectivity)\n[![Docs](https://img.shields.io/cocoapods/metrics/doc-percent/PeerConnectivity.svg)](http://cocoadocs.org/docsets/PeerConnectivity)\n[![License: MIT](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)]()\n\n#### A functional wrapper for the MultipeerConnectivity framework. \n\n#### PeerConnectivity is meant to have a lightweight easy to use syntax, be extensible and flexible, and handle the heavy lifting and edge cases of the MultipeerConnectivity framework quietly in the background. \n\n#### Please open an issue or submit a pull request if you have any suggestions!\n\n#### 🔌 Blog post [https://goo.gl/HJcMbE](https://goo.gl/HJcMbE)\n\n## Installation\n\n#### Cocoapods\n\nThe easiest way to get started is to use [CocoaPods](http://cocoapods.org/). Just add the following line to your Podfile:\n\n```ruby\npod 'PeerConnectivity', '~\u003e 0.5.4'\n```\n\n#### Carthage\n\n```ruby\ngithub \"rchatham/PeerConnectivity\"\n```\n\n\n## Creating/Stopping/Starting\n\n```swift\nvar pcm = PeerConnectionManager(serviceType: \"local\")\n\n// Start\npcm.start()\n\n// Stop\n//  - You should always stop the connection manager \n//    before attempting to create a new one\npcm.stop()\n\n// Can join chatrooms using PeerConnectionType.Automatic, .InviteOnly, and .Custom\n//  - .Automatic : automatically searches and joins other devices with the same service type\n//  - .InviteOnly : provides a browserViewController and invite alert controllers\n//  - .Custom : no default behavior is implemented\n\n// The manager can be initialized with a contructed peer representing the local user\n// with a custom displayName\n\npcm = PeerConnectionManager(serviceType: \"local\", connectionType: .Automatic, displayName: \"I_AM_KING\")\n\n// Start again at any time\npcm.start() {\n    // Do something when finished starting the session\n}\n```\n\n## Sending Events to Peers\n\n```swift\nlet event: [String: Any] = [\n    \"EventKey\" : Date()\n]\n\n// Sends to all connected peers\npcm.sendEvent(event)\n\n\n// Use this to access the connectedPeers\nlet connectedPeers: [Peer] = pcm.connectedPeers\n\n// Events can be sent to specific peers\nif let somePeerThatIAmConnectedTo = connectedPeers.first {\n   pcm.sendEvent(event, toPeers: [somePeerThatIAmConnectedTo])\n}\n```\n\n## Listening for Events\n\n```swift\n// Listen to an event\npcm.observeEventListenerForKey(\"someEvent\") { (eventInfo, peer) in\n    \n    print(\"Received some event \\(eventInfo) from \\(peer.displayName)\")\n    guard let date = eventInfo[\"eventKey\"] as? Date else { return }\n    print(date)\n    \n}\n\n// Stop listening to an event\npcm.removeListenerForKey(\"SomeEvent\")\n```\n\n## Acknowledgments\n\nIcon from the [Noun Project](https://thenounproject.com/search/?q=circle+people\u0026i=125108).\n\n\n### Helpful links \n\n- Check out the [Demo project](https://github.com/rchatham/PeerConnectivity/tree/master/PeerConnectivityDemo) and [Playground](https://github.com/rchatham/PeerConnectivity/blob/master/PeerPlayground.playground/Contents.swift) for examples to help you take you're app to the next level!!!\n\n- Read the [docs!](http://reidchatham.com/docs/PeerConnectivity/index.html)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frchatham%2FPeerConnectivity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frchatham%2FPeerConnectivity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frchatham%2FPeerConnectivity/lists"}