# Client

interface Client

Interface which duplicates AIDL client-side interface

In terms of NEXO Projects:

- Server is a listener, which wait for commands from Client to handle and response to Client

- Client is initiator which can send commands to Server and handles responses

Communication flow looks like this:

        Client[process A] Server[process B]
        1. Client ─── connect ──► Server "saves it's reference on side of process A"
        2. Server ◄── bind ─── Client "saves it's reference on side of process B"
        3. Client ─── calls ──► Server::onMessage
        4. Server ─── handles message: String ──► Result ──┐
                                                           │
        5.                                   [calls ──► Client::onMessage]
                                                           │
        6.                           Responses to client◄──┘

Content copied to clipboard

Reconnection flow has two cases:

    1. Connection was not established from first connecting
    2. Connection was lost during communication

Content copied to clipboard

There are two types of policy of resolving this issue:

- Reset - resets the connection

- Reconnect - tries to reconnect to server again with configurable amounts of tries with configured timeouts

- For Reconnection flow 1 - default policy Reset

- For Reconnection flow 2 - default policy Reconnect. If after retries connection was not re-established, Client will try to connect to Server when it have new command

## Functions

getApplicationName
Link copied to clipboard
abstract fun getApplicationName(): String
getClientVersion
Link copied to clipboard
abstract fun getClientVersion(): String
getPackage
Link copied to clipboard
abstract fun getPackage(): String
getProtocolVersion
Link copied to clipboard
abstract fun getProtocolVersion(protocolName: ProtocolName): String?
notifyEvent
Link copied to clipboard
abstract fun notifyEvent(event: Event)
onMessage
Link copied to clipboard
abstract fun onMessage(message: String?)

message handler

requestForeground
Link copied to clipboard
abstract fun requestForeground()

This method would be called by remote application, once it would require Client's application to become foreground.

requestForegroundState
Link copied to clipboard
abstract fun requestForegroundState(state: TransactionState?)

This method would be called by remote application, once it would require Client's application to become foreground.