WsProtocol

abstract class WsProtocol(webSocketConnection: WebSocketConnection, listener: WsProtocol.Listener)

A WsProtocol is responsible for handling the details of the WebSocket protocol.

Implementations must implement WsProtocol.handleServerMessage, WsProtocol.startOperation, WsProtocol.stopOperation

WsProtocol.handleServerMessage, WsProtocol.startOperation, WsProtocol.stopOperation all share the same thread and rely on webSocketConnection to do the operations async

Parameters

webSocketConnection

the connection

listener

a listener

Inheritors

Constructors

Link copied to clipboard
constructor(webSocketConnection: WebSocketConnection, listener: WsProtocol.Listener)

Types

Link copied to clipboard
interface Factory
Link copied to clipboard
interface Listener

Functions

Link copied to clipboard
open fun close()

Closes the connection gracefully. It is expected that a future call to WsProtocol.Listener.networkError is made

Link copied to clipboard
abstract suspend fun connectionInit()

Initializes the connection and suspends until the server acknowledges it.

Link copied to clipboard
abstract fun handleServerMessage(messageMap: Map<String, Any?>)

Handles a server message and notifies listener appropriately

Link copied to clipboard
open suspend fun run()

Read the WebSocket

Link copied to clipboard
abstract fun <D : Operation.Data> startOperation(request: ApolloRequest<D>)

Starts the given operation

Link copied to clipboard
abstract fun <D : Operation.Data> stopOperation(request: ApolloRequest<D>)

Stops the given operation