commonMain.org.hildan.socketio.EngineIOPacket.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of socketio-kotlin Show documentation
Show all versions of socketio-kotlin Show documentation
A Kotlin parser for Socket.IO / Engine.IO packet decoding
The newest version!
package org.hildan.socketio
import kotlinx.serialization.Serializable
/**
* An Engine.IO packet, as defined in the [Engine.IO protocol](https://socket.io/docs/v4/engine-io-protocol).
*/
sealed interface EngineIOPacket {
/**
* Used during the handshake.
*/
@Serializable
data class Open(
/** The session ID. */
val sid: String,
/** The list of available transport upgrades. */
val upgrades: List,
/** The ping interval, used in the heartbeat mechanism (in milliseconds). */
val pingInterval: Int,
/** The ping timeout, used in the heartbeat mechanism (in milliseconds). */
val pingTimeout: Int,
/** Optional, only useful when using long-polling as transport to know how many packets to batch together. */
val maxPayload: Int? = null,
) : EngineIOPacket
/**
* Used to indicate that a transport can be closed.
*/
data object Close : EngineIOPacket
/**
* Used during the upgrade process.
*/
data object Upgrade : EngineIOPacket
/**
* Used during the upgrade process.
*/
data object Noop : EngineIOPacket
/**
* Used in the heartbeat mechanism.
*/
data class Ping(val payload: String?) : EngineIOPacket
/**
* Used in the heartbeat mechanism.
*/
data class Pong(val payload: String?) : EngineIOPacket
/**
* Used to send a payload to the other side.
*/
data class Message(val payload: T) : EngineIOPacket
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy