public class DefaultWebSocketSessionImpl implements DefaultWebSocketSession, WebSocketSession
Default web socket session implementation that handles ping-pongs, close sequence and frame fragmentation
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultWebSocketSessionImpl.Companion |
WebSocketSession.DefaultImpls| Modifier and Type | Field and Description |
|---|---|
static DefaultWebSocketSessionImpl.Companion |
Companion |
| Constructor and Description |
|---|
DefaultWebSocketSessionImpl(WebSocketSession raw,
long pingInterval,
long timeoutMillis,
kotlinx.io.pool.ObjectPool<java.nio.ByteBuffer> pool)
Default web socket session implementation that handles ping-pongs, close sequence and frame fragmentation
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
close(java.lang.Throwable cause,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Close session with the specified cause or with no reason if
null |
java.lang.Object |
flush(kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Flush all outstanding messages and suspend until all earlier sent messages will be written. Could be called
at any time even after close. May return immediately if the connection is already terminated.
However it may also fail with an exception (or cancellation) at any point due to session failure.
Please note that
WebSocketSession.flush doesn't guarantee that frames were actually delivered. |
kotlinx.coroutines.Deferred<io.ktor.http.cio.websocket.CloseReason> |
getCloseReason()
A close reason for this session. It could be
null if a session is terminated with no close reason
(for example due to connection failure). |
kotlin.coroutines.CoroutineContext |
getCoroutineContext() |
NonExistentClass |
getDispatcher()
Deprecated.
|
kotlinx.coroutines.channels.ReceiveChannel<io.ktor.http.cio.websocket.Frame> |
getIncoming()
Incoming frames channel
|
boolean |
getMasking()
Enable or disable masking output messages by a random xor mask.
Please note that changing this flag on the fly could be applied to the messages already sent (enqueued earlier)
as the sending pipeline works asynchronously
|
long |
getMaxFrameSize()
Specifies frame size limit. Connection will be closed if violated
|
kotlinx.coroutines.channels.SendChannel<io.ktor.http.cio.websocket.Frame> |
getOutgoing()
Outgoing frames channel. It could have limited capacity so sending too much frames may lead to suspension at
corresponding send invocations. It also may suspend if a peer doesn't read frames for some reason.
|
long |
getPingIntervalMillis()
Ping interval or
-1L to disable pinger. Please note that pongs will be handled despite of this setting. |
long |
getTimeoutMillis()
A timeout to wait for pong reply to ping otherwise the session will be terminated immediately.
|
java.lang.Object |
goingAway(java.lang.String message,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Close session with GOING_AWAY reason
|
java.lang.Object |
send(Frame frame,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Enqueue frame, may suspend if outgoing queue is full. May throw an exception if outgoing channel is already
closed so it is impossible to transfer any message. Frames that were sent after close frame could be silently
ignored. Please note that close frame could be sent automatically in reply to a peer close frame unless it is
raw websocket session.
|
void |
setMasking(boolean p)
Enable or disable masking output messages by a random xor mask.
Please note that changing this flag on the fly could be applied to the messages already sent (enqueued earlier)
as the sending pipeline works asynchronously
|
void |
setMaxFrameSize(long p)
Specifies frame size limit. Connection will be closed if violated
|
void |
setPingIntervalMillis(long newValue)
Ping interval or
-1L to disable pinger. Please note that pongs will be handled despite of this setting. |
void |
setTimeoutMillis(long p)
A timeout to wait for pong reply to ping otherwise the session will be terminated immediately.
|
void |
terminate()
Initiate connection termination immediately. Termination may complete asynchronously.
|
getCloseReason, getPingIntervalMillis, getTimeoutMillis, setPingIntervalMillis, setTimeoutMillisclose, flush, getDispatcher, getIncoming, getMasking, getMaxFrameSize, getOutgoing, send, setMasking, setMaxFrameSize, terminatepublic static DefaultWebSocketSessionImpl.Companion Companion
public DefaultWebSocketSessionImpl(WebSocketSession raw, long pingInterval, long timeoutMillis, kotlinx.io.pool.ObjectPool<java.nio.ByteBuffer> pool)
Default web socket session implementation that handles ping-pongs, close sequence and frame fragmentation
timeoutMillis - A timeout to wait for pong reply to ping otherwise the session will be terminated immediately.It doesn't have any effect if DefaultWebSocketSession.getPingIntervalMillis is -1 (pinger is disabled).public kotlinx.coroutines.channels.ReceiveChannel<io.ktor.http.cio.websocket.Frame> getIncoming()
Incoming frames channel
public kotlinx.coroutines.channels.SendChannel<io.ktor.http.cio.websocket.Frame> getOutgoing()
Outgoing frames channel. It could have limited capacity so sending too much frames may lead to suspension at corresponding send invocations. It also may suspend if a peer doesn't read frames for some reason.
public kotlinx.coroutines.Deferred<io.ktor.http.cio.websocket.CloseReason> getCloseReason()
A close reason for this session. It could be null if a session is terminated with no close reason
(for example due to connection failure).
public long getPingIntervalMillis()
Ping interval or -1L to disable pinger. Please note that pongs will be handled despite of this setting.
public void setPingIntervalMillis(long newValue)
Ping interval or -1L to disable pinger. Please note that pongs will be handled despite of this setting.
public java.lang.Object goingAway(java.lang.String message,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Close session with GOING_AWAY reason
public java.lang.Object close(java.lang.Throwable cause,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Close session with the specified cause or with no reason if null
public long getTimeoutMillis()
A timeout to wait for pong reply to ping otherwise the session will be terminated immediately.
It doesn't have any effect if DefaultWebSocketSession.getPingIntervalMillis is -1 (pinger is disabled).
public void setTimeoutMillis(long p)
A timeout to wait for pong reply to ping otherwise the session will be terminated immediately.
It doesn't have any effect if DefaultWebSocketSession.getPingIntervalMillis is -1 (pinger is disabled).
p - A timeout to wait for pong reply to ping otherwise the session will be terminated immediately.It doesn't have any effect if DefaultWebSocketSession.getPingIntervalMillis is -1 (pinger is disabled).DefaultWebSocketSession.getPingIntervalMillispublic kotlin.coroutines.CoroutineContext getCoroutineContext()
public NonExistentClass getDispatcher()
Dispatcher to handle io operations
public boolean getMasking()
Enable or disable masking output messages by a random xor mask. Please note that changing this flag on the fly could be applied to the messages already sent (enqueued earlier) as the sending pipeline works asynchronously
public void setMasking(boolean p)
Enable or disable masking output messages by a random xor mask. Please note that changing this flag on the fly could be applied to the messages already sent (enqueued earlier) as the sending pipeline works asynchronously
public long getMaxFrameSize()
Specifies frame size limit. Connection will be closed if violated
public void setMaxFrameSize(long p)
Specifies frame size limit. Connection will be closed if violated
public java.lang.Object flush(kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Flush all outstanding messages and suspend until all earlier sent messages will be written. Could be called
at any time even after close. May return immediately if the connection is already terminated.
However it may also fail with an exception (or cancellation) at any point due to session failure.
Please note that WebSocketSession.flush doesn't guarantee that frames were actually delivered.
WebSocketSession.flushpublic java.lang.Object send(Frame frame, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> p)
Enqueue frame, may suspend if outgoing queue is full. May throw an exception if outgoing channel is already closed so it is impossible to transfer any message. Frames that were sent after close frame could be silently ignored. Please note that close frame could be sent automatically in reply to a peer close frame unless it is raw websocket session.
public void terminate()
Initiate connection termination immediately. Termination may complete asynchronously.