newWebSocket

abstract fun newWebSocket(url: String, headers: List<HttpHeader> = emptyList(), listener: WebSocketListener): WebSocket

Creates a new WebSocket.

The WebSocket is garbage collected when not used anymore. Call WebSocket.close to close the websocket and release resources earlier. You don't need to call WebSocket.close if:

Parameters

url

: an url starting with one of:

  • ws://

  • wss://

  • http://

  • https://

If the underlying engine requires a ws or wss, http and https are replaced by ws and wss respectively