WebSocketSession

Defines session for WebSocket connection.

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def close(code: StatusCode): Unit

Closes session with supplied status code.

Closes session with supplied status code.

Value Params
code

status code of closure

def id: String

Gets session identifer.

Gets session identifer.

def idleTimeout: Int

Gets WebSocket idle timeout in milliseconds.

Gets WebSocket idle timeout in milliseconds.

Timeout of zero disables this option – i.e., timeout is indefinite.

Note

If no activity transpires for specified duration, then session is closed with status code GoingAway.

def idleTimeout(milliseconds: Int): WebSocketSession

Sets WebSocket idle timeout.

Sets WebSocket idle timeout.

Timeout of zero disables this option – i.e., timeout is indefinite.

Value Params
milliseconds

idle timeout

Returns

this session

Note

If no activity transpires for specified duration, then session is closed with status code GoingAway.

def isSecure: Boolean

Tests for secure WebSocket session.

Tests for secure WebSocket session.

Gets logger associated with session.

Gets logger associated with session.

Gets capacity of incoming message.

Gets capacity of incoming message.

Note

If message exceeds specified capacity, then session is closed with status code MessageTooBig.

Sets capacity of incoming message.

Sets capacity of incoming message.

Value Params
size

message capacity in bytes

Returns

this session

Note

If message exceeds specified capacity, then session is closed with status code MessageTooBig.

def onBinary[T](handler: Array[Byte] => T): WebSocketSession

Sets handler for incoming binary message.

Sets handler for incoming binary message.

Value Params
handler

binary message handler

Returns

this session

def onClose[T](handler: StatusCode => T): WebSocketSession

Sets handler to be notified when session closes.

Sets handler to be notified when session closes.

Value Params
handler

close handler

Returns

this session

def onError[T](handler: Throwable => T): WebSocketSession

Sets handler to be notified when session error occurs.

Sets handler to be notified when session error occurs.

Value Params
handler

error handler

Returns

this session

def onPing[T](handler: Array[Byte] => T): WebSocketSession

Sets handler for incoming ping message.

Sets handler for incoming ping message.

Value Params
handler

ping message handler

Returns

this session

def onPong[T](handler: Array[Byte] => T): WebSocketSession

Sets handler for incoming pong message.

Sets handler for incoming pong message.

Value Params
handler

pong message handler

Returns

this session

def onText[T](handler: String => T): WebSocketSession

Sets handler for incoming text message.

Sets handler for incoming text message.

Value Params
handler

text message handler

Returns

this session

def open(): Unit

Opens session.

Opens session.

Note

This method becomes an effective no-op if invoked more than once.

def payloadLimit: Int

Gets payload limit of outgoing message.

Gets payload limit of outgoing message.

Note

If outgoing message exceeds specified limit, then message is sent over multiple frames.

def payloadLimit(length: Int): WebSocketSession

Gets payload limit of outgoing message.

Gets payload limit of outgoing message.

Value Params
length

payload limit in bytes

Returns

this session

Note

If outgoing message exceeds specified limit, then message is sent over multiple frames.

def ping(data: Array[Byte]): Unit

Sends ping message.

Sends ping message.

Value Params
data

application data to accompany ping message

def pingAsync[T](data: Array[Byte]): Future[Unit]

Sends ping message asynchronously and on completion passes result to supplied callback.

Sends ping message asynchronously and on completion passes result to supplied callback.

Value Params
callback

result handler

data

application data to accompany ping message

def pong(data: Array[Byte]): Unit

Sends pong message.

Sends pong message.

Value Params
data

application data to accompany pong message

def pongAsync[T](data: Array[Byte]): Future[Unit]

Sends pong message asynchronously and on completion passes result to supplied callback.

Sends pong message asynchronously and on completion passes result to supplied callback.

Value Params
callback

result handler

data

application data to accompany pong message

def protocolVersion: String

Gets WebSocket protocol version.

Gets WebSocket protocol version.

def send(message: String): Unit

Sends text message.

Sends text message.

Value Params
message

text message

def send(message: Array[Byte]): Unit

Sends binary message.

Sends binary message.

Value Params
message

binary message

def send(message: InputStream, binary: Boolean): Unit

Sends message.

Sends message.

If binary is true, then binary message is sent; otherwise, text message is sent.

Value Params
binary

indicator for binary message

message

input stream to message

def sendAsync[T](message: String): Future[Unit]

Sends text message asynchronously and on completion passes result to supplied callback.

Sends text message asynchronously and on completion passes result to supplied callback.

Value Params
callback

result handler

message

text message

def sendAsync[T](message: Array[Byte]): Future[Unit]

Sends binary message asynchronously and on completion passes result to supplied callback.

Sends binary message asynchronously and on completion passes result to supplied callback.

Value Params
callback

result handler

message

binary message

def sendAsync[T](message: InputStream, binary: Boolean): Future[Unit]

Sends message asynchronously and on completion passes result to supplied callback.

Sends message asynchronously and on completion passes result to supplied callback.

If binary is true, then binary message is sent; otherwise, text message is sent.

Value Params
binary

indicator for binary message

callback

result handler

message

input stream to message

Gets current state of WebSocket session.

Gets current state of WebSocket session.

def target: Uri

Gets target of WebSocket request.

Gets target of WebSocket request.