WebsocketContentConverter

A custom content converter that could be used in the WebSockets plugin Could provide bi-directional conversion implementation. One of the most typical examples of the content converter is a JSON converter that provides both serialization and deserialization

Implementations must override at least one of serialize or serializeNullable methods.

Functions

Link copied to clipboard
abstract suspend fun deserialize(charset: Charset, typeInfo: TypeInfo, content: Frame): Any?

Deserializes content to the value of type typeInfo

Link copied to clipboard
abstract fun isApplicable(frame: Frame): Boolean

Checks if the content converter can deserialize a frame

Link copied to clipboard
open suspend fun serialize(charset: Charset, typeInfo: TypeInfo, value: Any): Frame

Serializes a value to a WebSocket Frame. This function could throw WebsocketConverterNotFoundException if the value is not suitable for conversion

Link copied to clipboard
open suspend fun serializeNullable(charset: Charset, typeInfo: TypeInfo, value: Any?): Frame

Serializes a value to a WebSocket Frame. This function could throw WebsocketConverterNotFoundException if the value is not suitable for conversion

Extensions

Link copied to clipboard
inline suspend fun <T> WebsocketContentConverter.deserialize(content: Frame, charset: Charset = Charsets.UTF_8): T

Deserializes content to the value of type T

Link copied to clipboard
inline suspend fun <T> WebsocketContentConverter.serialize(value: T, charset: Charset = Charsets.UTF_8): Frame

Serializes a value to a WebSocket Frame. This function could throw WebsocketConverterNotFoundException if the value is not suitable for conversion