public final class IncomingConnection
- Object
- IncomingConnection
An incoming request from another device that wants to connect, delivered
to TransportListener.connectionRequested.
Named IncomingConnection rather than the obvious ConnectionRequest
because com.codename1.io.ConnectionRequest is one of the most widely used
classes in the framework, and an app doing both networking and nearby
transport – which is most of them – would have had to qualify one of the
two at every mention.
Answer it with accept() or reject(). A request that is never
answered times out on the far side, so answer every one – and answer it
promptly, because both platforms hold radio resources open meanwhile.
Show the token
getAuthenticationToken() is a short string both devices compute from
the connection, and it is the only defense against a device in the middle
pretending to be the one the user meant. Showing it on both screens and
asking “do these match?” is what makes the pairing trustworthy; skipping
that step is a choice to trust whoever answered first.
Methods
public Endpoint getEndpoint() | Who is asking. |
public String getAuthenticationToken() | The short string both devices derive from this connection’s key exchange. |
public boolean isAnswered() | Whether accept() or reject() has already been called. |
public void accept() | Accepts the connection. |
public void reject() | Rejects the connection. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Method details
getEndpoint
public Endpoint getEndpoint()getAuthenticationToken
public String getAuthenticationToken()The short string both devices derive from this connection’s key exchange. Identical on both sides when nothing is in the middle.
Never null, and empty on iOS: MultipeerConnectivity offers no material to bind a token to, and inventing one from the service name and display names would produce matching digits at both ends of a relay. Treat empty as “this platform cannot answer the question”.
isAnswered
public boolean isAnswered()accept
public void accept()TransportListener.connected or
TransportListener.connectionFailed, because the far side has to
accept too. Calling this twice, or after reject(), does nothing.reject
public void reject()accept(),
does nothing.toString
public String toString()