API Reference
Complete reference documentation for the LiteP2P SDK. This section covers all public classes, methods, and interfaces.
Core Classes
LiteP2P
Main entry point for the SDK. Handles initialization, connection, and peer discovery.
PeerConfig
Configuration options for LiteP2P initialization.
Connection Classes
Connection
Represents an active connection to the P2P network.
Peer
Represents a remote peer in the network.
PeerState
Enumeration of possible peer connection states.
Messaging
Message
Inbound message envelope containing sender and payload.
SendResult
Outcome of a send attempt with error and trace details.
File Transfer
FileTransfer
Represents an in-flight transfer with progress and completion callbacks.
TransferOptions
Options for chunking, resumption, and integrity verification.
Quick Reference
Initialization
// Initialize LiteP2P
val config = PeerConfig.Builder()
.setAppId("your-app-id")
.build()
LiteP2P.initialize(context, config)
// Get singleton instance
val p2p = LiteP2P.getInstance()
Connection
// Connect to network
p2p.connect { result -> }
// Disconnect
p2p.disconnect()
// Check connection status
val isConnected = p2p.isConnected()
Messaging
// Send message
p2p.sendMessage(peerId, data) { result -> }
// Receive messages
p2p.onMessage { message -> }
File Transfer
// Send file
val transfer = p2p.sendFile(peerId, file, options)
// Monitor progress
transfer.onProgress { progress -> }
transfer.onComplete { result -> }
Type Reference
| Type | Description |
|---|---|
PeerId |
Unique identifier for a peer (String alias) |
Peer |
Remote peer identity and metadata |
PeerState |
Peer connection lifecycle state |
AppId |
Your application's unique identifier |
MessageData |
ByteArray containing message payload |
ConnectionResult |
Sealed class with Success/Error variants |
SendResult |
Outcome of a send attempt (accepted/error + trace) |
FileTransfer |
In-flight transfer handle (progress/cancel) |
TransferOptions |
Transfer configuration (chunk size, resume, verify) |