Module ringo/webapp/websocket

adds support for Websockets to Ringo webapps.

Functions

Class WebSocket

Instance Methods

Instance Properties


WebSocket

The WebSocket object passed as argument to the connect callback. Assign callbacks to its onmessage and onclose properties.


WebSocket.prototype.close ()

Closes the WebSocket connection.


WebSocket.prototype.getSession ()

Get the HTTP Session object associated with this WebSocket.


WebSocket.prototype.isOpen ()

Check whether the WebSocket is open.


WebSocket.prototype.onclose

Callback slot for getting notified when the WebSocket is closed. To get called when the WebSocket is closed assign a function to this property. The function is called without arguments.


WebSocket.prototype.onmessage

Callback slot for receiving messages on this WebSocket. To receive messages on this WebSocket, assign a function to this property. The function is called with a single argument containing the message string.


WebSocket.prototype.send (msg)

Send a string over the WebSocket.

Parameters

msg a string

addWebSocket (context, path, onconnect)

Start accepting WebSocket connections in the given ringo/httpserver context.

Parameters

context The ringo/httpserver Server context
path The URL path on which to accept WebSocket connections
onconnect a function called for each new WebSocket connection with the WebSocket object as argument.