scoop:scoop.http.asyncio:0.1.0
src/websocket/options.scoop
Selected production source · src/websocket/options.scoop
1
package scoop.http.asyncio3
import scoop.http.*4
import scoop.time.Duration6
/**7
* Incoming frame limits, bounded read/write buffers, graceful-close deadline, and8
* decompressed-message limit for a WebSocket session.9
*/10
public class WebSocketSessionOptions internal constructor(11
/**12
* Limits applied to incoming wire frames and messages.13
*/14
public val incomingLimits: WebSocketFrameLimits = WebSocketFrameLimits(),15
/**16
* The positive transport input buffer capacity.17
*/18
public val inputBufferBytes: Long = 8192L,19
/**20
* The positive maximum payload chunk used for streamed output frames.21
*/22
public val outgoingFrameBytes: Long = 8192L,23
/**24
* The deadline used by graceful close negotiation.25
*/26
public val closeTimeout: Duration = Duration.seconds(5L),27
/**28
* The separate limit on decoded message size; by default it follows the incoming wire-message29
* limit.30
*/31
public val maxDecompressedMessageBytes: Long = incomingLimits.maxMessageBytes32
) {33
init {34
if (35
inputBufferBytes <=36
0L ||37
outgoingFrameBytes <=38
0L ||39
outgoingFrameBytes >40
Long.MAX_VALUE -41
14L42
)43
throw IllegalArgumentException(Some("invalid WebSocket stream buffer size"))44
if (closeTimeout <= Duration.ZERO)45
throw IllegalArgumentException(Some("WebSocket close timeout must be positive"))46
if (maxDecompressedMessageBytes < 0L)47
throw IllegalArgumentException(Some("negative decompressed message limit"))48
}49
}51
/**52
* Session-lifecycle failures distinct from low-level frame validation errors.53
*/54
public enum WebSocketFailureKind {55
/**56
* The operation requires an open session or message.57
*/58
Closed,59
/**60
* The transport ended without the expected WebSocket closure.61
*/62
UnexpectedEof,63
/**64
* A message was abandoned before its boundary completed.65
*/66
InterruptedMessage,67
/**68
* The peer did not complete the close handshake before its deadline.69
*/70
CloseTimeout71
}73
/**74
* A session failure with portable kind, explanatory text, optional peer close, and original cause.75
*/76
public class WebSocketSessionException public constructor(77
/**78
* The session-lifecycle failure category.79
*/80
public val kind: WebSocketFailureKind,81
/**82
* The reason the operation failed.83
*/84
public val detail: String,85
/**86
* The peer's close frame when one was received.87
*/88
public val peerClose: WebSocketClose? = None,89
/**90
* The underlying I/O, protocol, or callback exception when available.91
*/92
public val cause: Throwable? = None93
): Exception(Some("WebSocket session: " + detail))