MultipeerKit

0.3.1

MultipeerConnectivity + Codable = ❤️
hallee/MultipeerKit

What's New

2020-09-08T20:25:28Z

MultipeerKit

A high-level abstraction built on top of the MultipeerConnectivity framework, which allows iOS, macOS and tvOS devices to exchange data between them over Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth.

Sample app

Check the example folder for a sample implementation.

Sample

Usage

The main class in this library is MultipeerTransceiver, which does both the sending and receiving aspects of the multipeer communication.

MultipeerKit can transmit and receive anything that conforms to the Codable protocol, which makes it easy for you to define your own message types.

// Create a transceiver (make sure you store it somewhere, like a property)
let transceiver = MultipeerTransceiver()

// Start it up!
transceiver.resume()

// Configure message receivers
transceiver.receive(SomeCodableThing.self) { payload, sender in
print("Got my thing from \(sender.name)! \(payload)")
}

// Broadcast message to peers
let payload = SomeEncodableThing()
transceiver.broadcast(payload)

For more information on how to use MultipeerKit, check out the documentation.

Integrating

MultipeerKit is a Swift package, to use it in your project, add this to your Package.swift file:

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/insidegui/MultipeerKit.git", from: "0.2.0")
    ],
    ...
)

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed Nov 20 2024 22:54:33 GMT-1000 (Hawaii-Aleutian Standard Time)