package com.codename1.nearby.transport
Sending bytes and files to a device in the same room, with no access point, no pairing and no internet.
Start at NearbyTransport.
Read the limitation before designing around this
This transport does not cross ecosystems. It is Google’s Nearby Connections on Android and Apple’s MultipeerConnectivity on iOS, and the two share no wire protocol, so an Android phone and an iPhone will never discover each other here no matter how the app is written. The API does not hide that, because an API that looked portable and silently never found the peer would be worse.
When both ends of the conversation are not the same platform, the
framework already has two options that do work across the divide:
com.codename1.bluetooth.le.L2capChannel for a raw byte stream over BLE,
and com.codename1.io.bonjour plus sockets when both devices share a
Wi-Fi network.
Types
class Endpoint | Another device seen advertising the same service id. |
class IncomingConnection | An incoming request from another device that wants to connect, delivered to TransportListener.connectionRequested. |
class NearbyTransport | Moving bytes and files to a device that is physically nearby, with no access point, no pairing and no internet. |
class Payload | Something to send to a connected endpoint: either a block of bytes or a file. |
enum PayloadStatus | Where a payload transfer got to, carried by PayloadTransferUpdate. |
class PayloadTransferUpdate | Progress on one payload, delivered to TransportListener.payloadProgress. |
class TransportAdapter | A TransportListener whose methods all do nothing, so a caller interested in two events overrides two methods. |
interface TransportListener | Receives everything the nearby transport has to say. |
enum TransportStrategy | The connection topology a transport session uses. |