Class DataTransport

  • Direct Known Subclasses:
    DataTransportHttp, DataTransportNfc

    public abstract class DataTransport
    extends java.lang.Object
    Abstraction for data transfer between prover and verifier devices.

    The data transfer is packetized, that is, data is delivered at the same granularity as it is sent. For example, if sendMessage(byte[]) is used to send N bytes then this blob is what the remote peer will receive in the DataTransport.Listener.onMessageReceived() callback.

    Instances constructed from subclasses deriving from this class must be inert when constructed, that is, they must not do anything. This constraint exists to easily facilitate factory-patterns.

    If an unrecoverable error is detected, this is conveyed using the DataTransport.Listener.onError(Throwable) callback.

    This class can be used to implement both provers and verifiers.

    • Method Detail

      • getMessage

        @Nullable
        public byte[] getMessage()
        Returns the next message received, if any.
        Returns:
        the next message or null if none is available.
      • inhibitCallbacks

        protected void inhibitCallbacks()
      • reportConnectionMethodReady

        protected void reportConnectionMethodReady()
      • reportConnecting

        protected void reportConnecting()
      • reportConnected

        protected void reportConnected()
      • reportDisconnected

        protected void reportDisconnected()
      • reportMessageReceived

        protected void reportMessageReceived​(@NonNull
                                             byte[] data)
      • reportMessageProgress

        protected void reportMessageProgress​(long progress,
                                             long max)
      • reportTransportSpecificSessionTermination

        protected void reportTransportSpecificSessionTermination()
      • reportError

        protected void reportError​(@NonNull
                                   java.lang.Throwable error)
      • getConnectionMethod

        @NonNull
        public abstract ConnectionMethod getConnectionMethod()
        Returns a ConnectionMethod instance that can be used to connect to this transport.

        This is used for listening transports where the address to listen on is not known until the connection has been set up for example if dynamic TCP port assignments are used or cloud relays.

        For most data transports this will return the same ConnectionMethod instance that was passed at construction time. However for some transports where the address to listen on is not known until the connection have been set up (for example dynamic TCP listening port assignments or when a cloud relay is in use) it will differ.

        This cannot be called until the DataTransport.Listener.onConnectionMethodReady() callback has been fired.

        Returns:
        A ConnectionMethod-derived instance.