RingoJS

Module ringo/httpserver/websocket

Properties

Class WebSocket

Instance Methods


EventSource

Provides support for WebSocket connections in the HTTP server.

WebSocket is an event emitter that supports the following events:

  • connect: called when a new websocket connection is accepted
  • close: called when an established websocket connection closes
  • text: called when a text message arrived
  • binary: called when a binary message arrived
  • error: called when an error occurred

WebSocket

Not exported as constructor by this module.


WebSocket.prototype. close ()

Closes the WebSocket connection.


WebSocket.prototype. isOpen ()

Check whether the WebSocket is open.

Returns

Boolean

true if the connection is open


WebSocket.prototype. send (message)

Deprecated!

Send a string over the WebSocket.

Parameters

String message

a string


WebSocket.prototype. sendBinary (byteArray, offset, length)

Send a byte array over the WebSocket. This method blocks until the message as been transmitted.

Parameters

ByteArray byteArray

The byte array to send

Number offset

Optional offset (defaults to zero)

Number length

Optional length (defaults to the length of the byte array)


WebSocket.prototype. sendBinaryAsync (byteArray, offset, length)

Send a byte array over the WebSocket. This method does not wait until the message as been transmitted.

Parameters

ByteArray byteArray

The byte array to send

Number offset

Optional offset (defaults to zero)

Number length

Optional length (defaults to the length of the byte array)

Returns

Promise

A promise that is resolved or rejected


WebSocket.prototype. sendString (message)

Send a string over the WebSocket. This method blocks until the message has been transmitted

Parameters

String message

a string


WebSocket.prototype. sendStringAsync (message)

Send a string over the WebSocket. This method does not wait until the message as been transmitted.

Parameters

String message

a string

Returns

Promise

A promise that is resolved or rejected