Package dev.fritz2.remote

Types

Link copied to clipboard
abstract class Authentication<P> : Middleware

Special Middleware to use in at http API to provide an authentication for every request. The type-parameter P represents the principal information, which contains all login-information needed to authenticate against the external HTTP API. The principal information is held inside and available as flow by calling data. To use this Middleware you need to implement the addAuthentication method, where you get the principal information, when available, to add it to your requests. To implement the client side of authentication process you also need to implement the authenticate method in which you specify what is needed to authenticate the user (e.g. open up a login modal). When your authentication process is done you have to call the complete function and set your principal. Then all requests, that have been initialized while the authentication was running, will be re-executed with the additional authentication information provided by the addAuthentication method. When the user logs out you have to call the clear function to clear all authentication information.

Link copied to clipboard
class CloseException(message: String, throwable: Throwable) : Exception

Exception for handling errors with closing

Link copied to clipboard
class ConnectionException(message: String, throwable: Throwable) : Exception

Exception for handling errors with connecting

Link copied to clipboard
class FetchException(statusCode: Int, body: String, response: Response) : Exception

Exception type for handling http exceptions

Link copied to clipboard
interface Middleware

interface to do interceptions at http calls. It can modify each request and handles all responses in a specified way.

Link copied to clipboard
open class Request(url: String, method: String, headers: Map<String, String>, body: dynamic, referrer: String?, referrerPolicy: dynamic, mode: RequestMode?, credentials: RequestCredentials?, cache: RequestCache?, redirect: RequestRedirect?, integrity: String?, keepalive: Boolean?, reqWindow: Any?, middlewares: List<Middleware>)

Represents the common fields and attributes of an HTTP request.

Link copied to clipboard
open class Response(response: Response, request: Request, propagate: Boolean)

Represents the common fields and attributes of an HTTP response. It contains also the original Request which was made to get this Response.

Link copied to clipboard
class SendException(message: String) : Exception

Exception for handling errors with sending

Link copied to clipboard
open class Session(webSocket: WebSocket)

Session represents a session via websocket after connection was successful. Within a Session you can exchange data with the remote endpoint bi-directionaly.

Link copied to clipboard
sealed class SessionState

SessionState represents the actual state of the websocket connection. After connection is established it changes from SessionState.Connecting to SessionState.Open and when connection is closed it is SessionState.Closed.

Link copied to clipboard
open class Socket(baseUrl: String, protocols: Array<out String>)

Socket defines how to connect via websocket. Therefore, it needs an baseUrl and an optional list of protocols. The Session will be established after calling the connect method.

Functions

Link copied to clipboard
external fun btoa(decoded: String): String
Link copied to clipboard
fun http(baseUrl: String = ""): Request

creates a new Request

Link copied to clipboard
fun websocket(url: String, vararg protocols: String): Socket

creates a new Socket for bidirectional communication with the server.

Properties

Link copied to clipboard
val Flow<MessageEvent>.arrayBuffer: Flow<ArrayBuffer>

gives the MessageEvent.data as Flow of ArrayBuffer

Link copied to clipboard
val Flow<MessageEvent>.blob: Flow<Blob>

gives the MessageEvent.data as Flow of Blob

Link copied to clipboard
val Flow<MessageEvent>.body: Flow<String>

gives the MessageEvent.data as Flow of String

Link copied to clipboard
val Session.closes: Flow<CloseEvent>

gives a Flow of CloseEvent when Session closes

Link copied to clipboard
val Flow<MessageEvent>.data: Flow<Any?>

gives the MessageEvent.data as Flow of Any

Link copied to clipboard
val Session.isClosed: Flow<Boolean>

gives a Flow of Boolean when SessionState is SessionState.Closed

Link copied to clipboard
val Session.isConnecting: Flow<Boolean>
Link copied to clipboard
val Session.isOpen: Flow<Boolean>

gives a Flow of Boolean when SessionState is SessionState.Open

Link copied to clipboard
val Session.opens: Flow<Event>

gives a Flow of Event when Session opens