Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public interface TransportListener

Known subtypesTransportAdapter

Receives everything the nearby transport has to say. Every method is called on the EDT.

Extend TransportAdapter rather than implementing all of this.

Methods

public abstract void endpointFound(Endpoint endpoint)A peer advertising the same service id came into view.
public abstract void endpointLost(Endpoint endpoint)A discovered peer went away before any connection was made.
public abstract void connectionRequested(IncomingConnection request)A peer wants to connect.
public abstract void connected(Endpoint endpoint)A connection is open in both directions and payloads may be sent.
public abstract void connectionFailed(Endpoint endpoint, NearbyException error)A connection attempt failed, or was rejected by the far side.
public abstract void disconnected(Endpoint endpoint)An open connection closed, whether deliberately or because the peer went out of range.
public abstract void payloadReceived(Endpoint endpoint, Payload payload)A complete payload arrived.
public abstract void payloadProgress(Endpoint endpoint, PayloadTransferUpdate update)Progress on a payload being sent or received.

Method details

endpointFound

public abstract void endpointFound(Endpoint endpoint)
A peer advertising the same service id came into view. Expect this repeatedly for the same endpoint across discovery sessions.

Parameters

endpoint Endpoint
the peer that appeared

endpointLost

public abstract void endpointLost(Endpoint endpoint)
A discovered peer went away before any connection was made.

Parameters

endpoint Endpoint
the peer that disappeared

connectionRequested

public abstract void connectionRequested(IncomingConnection request)
A peer wants to connect. Call IncomingConnection.accept() or IncomingConnection.reject(); a request that is never answered times out on the far side.

Parameters

request IncomingConnection
the request to answer

connected

public abstract void connected(Endpoint endpoint)
A connection is open in both directions and payloads may be sent.

Parameters

endpoint Endpoint
the connected peer

connectionFailed

public abstract void connectionFailed(Endpoint endpoint, NearbyException error)
A connection attempt failed, or was rejected by the far side.

Parameters

endpoint Endpoint
the peer that did not connect
error NearbyException
why

disconnected

public abstract void disconnected(Endpoint endpoint)
An open connection closed, whether deliberately or because the peer went out of range.

Parameters

endpoint Endpoint
the peer that disconnected

payloadReceived

public abstract void payloadReceived(Endpoint endpoint, Payload payload)
A complete payload arrived.

Parameters

endpoint Endpoint
who sent it
payload Payload
what they sent

payloadProgress

public abstract void payloadProgress(Endpoint endpoint, PayloadTransferUpdate update)
Progress on a payload being sent or received.

Parameters

endpoint Endpoint
the other end of the transfer
update PayloadTransferUpdate
how far it has got