JavaXT
|
|
WebSocket ClassUsed to communicate with a server using web sockets. Currently, this is a read-only listener designed to get updates and status messages from the server. The listener will automatically reconnect to the server if the network connnection is interrupted.
var ws = new javaxt.dhtml.WebSocket({ url: "/live/stats", onMessage: function(msg){ console.log(msg); } }); var logout = function(){ ws.stop(); //stop listening to events and disconnect from the server }; ConstructorsConfig Optionsurl Relative path the to websocket endpoint (e.g. "/updates"). You do not need to specify a full url with a "ws://" or "wss://" prefix.
keepAlive Interval used to check whether the websocket is still alive and send ping messages. Value is in milliseconds. Default is 15000 (15 seconds).
debugr Class used to debug the websocket. This config is not required to use this class. Implementations must implement an append() method.
EventsonConnect( ) Called whenever a websocket connection is established with the server. Note that this event will be fired whenever a connection is dropped and then restablished. onFailure( code, reason ) Called whenever there is a problem connecting or reconnecting to the server. Public Methods |