Quick Integration Guide

Get up and running with LiteP2P in less than 5 minutes.

1. Add Dependency

Add the LiteP2P SDK to your project's build file.

Android (Gradle)

dependencies {
    implementation 'io.litep2p:sdk:2.0.0'
}

iOS (CocoaPods)

pod 'LiteP2P', '~> 2.0.0'

2. Initialize the SDK

Initialize the engine in your application startup logic.

// Android
class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()

        val config = PeerConfig.Builder()
            .setAppId("my-app-id")
            .build()

        LiteP2P.initialize(this, config)
    }
}

3. Connect and Communicate

Start the peer discovery and send your first message.

val p2p = LiteP2P.getInstance()

p2p.connect { result ->
    if (result.isSuccess) {
        Log.d("LiteP2P", "Connected to network!")

        // Broadcast a message
        val message = "Hello World".toByteArray()
        p2p.broadcast(message)
    }
}

Next Steps