Server

interface Server

Interface which duplicates AIDL Server-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◄──┘

Reconnection flow has two cases:

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

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

Link copied to clipboard
abstract fun bindClient(client: Client)

An asynchronous try to bind client

Link copied to clipboard
abstract fun getProtocolVersion(protocolName: ProtocolName): String?
Link copied to clipboard
abstract fun getServerVersion(): String
Link copied to clipboard
abstract fun isClientBound(client: Client): Boolean
Link copied to clipboard
abstract fun onMessageReceived(message: String)

message handler

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.

Link copied to clipboard
abstract fun restartService()

Would be called by Client's application in order to ask for restart

Link copied to clipboard
abstract fun unbindClient(client: Client)

An asynchronous try to unbind client