class web::WebSocket

sys::Obj
  web::WebSocket

Source

WebSocket is used for both client and server web socket messaging.

NOTE: This is API is a prototype only! Current implementation only supports basic non-fragmented text or binary messages.

close

Bool close()

Source

Close the web socket

openClient

const static WebSocket openClient(Uri uri, [Str:Str]? headers := null)

Source

Open a client connection. The URI must have a "ws" or "wss" scheme. The headers parameter defines additional HTTP headers to include in the connection request.

openServer

const static WebSocket openServer(WebReq req, WebRes res)

Source

Upgrade a server request to a WebSocket. Raise IOErr is there is any problems during the handshake in which case the calling WebMod should return a 400 response.

receive

Obj? receive()

Source

Receive a message which is returned as either a Str or Buf. Raise IOErr if socket is closed.

send

Void send(Obj msg)

Source

Send a message which must be either a Str of Buf.

socketOptions

SocketOptions socketOptions()

Source

Access to socket options for this request.