Abacus AppStateResponse contains IO requests which the FE app needs to process in platform code.
For every Abacus function which requires a AppStateResponse, FE app should check the networkRequests(NetworkRequests) field, and process network requests as needed.
When receiving the response from a HTTP request, FE should call appStateMachine.
data class NetworkRequests(
val socketRequests: Array<SocketRequest>?,
val restRequests: Array<RestRequest>?
)
data class SocketRequest(
val type: SocketRequestType,
val url: AbUrl,
val text: String?
)
FE app needs to process the socket request, which includes connecting the socket, send text to the channel, and close connection
SocketConnect
SocketText
SocketClose
The URL of the socket
For SocketRequestType of socketText, send the text to the socket
data class RestRequest(
val url: AbUrl,
val verb: HttpVerb,
val headers: NetworkParams?,
val body: String?,
)
URL for the HTTP request
GET, POST, PUT or DELETE
FE app should add the headers to the request as key-value pairs
For POST and PUT requests, send in the body
fun setSocketConnected(url: AbUrl, socketConnected: Boolean): AppStateResponse
When a websocket is connected or disconnected, FE should call AppStateMachine's setSocketConnected and process the response
URL of the socket
A boolean flag, whether the socket is connected or disconnected
fun processSocketResponse(url: AbUrl, text: String): AppStateResponse
Whenever FE app receives data from the socket, it should call Abacus processSocketResponse, and process the response
URL of the socket
Text data from the socket
fun processHttpResponse(url: AbUrl, text: String): AppStateResponse
When FE app receives a response from the HTTP request, call Abacus processHttpResponse, and process the response
URL of the HTTP request
Response body as text