Package org.cometd.javascript
Class WebSocketConnection
java.lang.Object
org.cometd.javascript.WebSocketConnection
- All Implemented Interfaces:
org.eclipse.jetty.websocket.api.WebSocketConnectionListener
,org.eclipse.jetty.websocket.api.WebSocketListener
public class WebSocketConnection
extends java.lang.Object
implements org.eclipse.jetty.websocket.api.WebSocketListener
This class is the underlying implementation of JavaScript's window.WebSocket
in browser.js
.
-
Constructor Summary
Constructors Constructor Description WebSocketConnection(JavaScript javaScript, java.lang.Object jsWebSocket, java.lang.Object connector, java.lang.String url, java.lang.String protocol)
This constructor is invoked frombrowser.js
, from thewindow.WebSocket
constructor. -
Method Summary
Modifier and Type Method Description void
close(int code, java.lang.String reason)
This method is invoked frombrowser.js
, from thewindow.WebSocket.close(code, reason)
function.void
onWebSocketBinary(byte[] payload, int offset, int len)
void
onWebSocketClose(int closeCode, java.lang.String reason)
void
onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session)
void
onWebSocketError(java.lang.Throwable x)
void
onWebSocketText(java.lang.String data)
void
send(java.lang.String data)
This method is invoked frombrowser.js
, from thewindow.WebSocket.send(data)
function.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
WebSocketConnection
public WebSocketConnection(JavaScript javaScript, java.lang.Object jsWebSocket, java.lang.Object connector, java.lang.String url, java.lang.String protocol)This constructor is invoked from
browser.js
, from thewindow.WebSocket
constructor.- Parameters:
javaScript
- the (java) JavaScript objectjsWebSocket
- the (javascript) WebSocket object created inbrowser.js
connector
- the (java) WebSocketConnector objecturl
- the WebSocket URL passed to thewindow.WebSocket(url, protocol)
constructorprotocol
- the WebSocket protocol passed to thewindow.WebSocket(url, protocol)
constructor
-
-
Method Details
-
send
public void send(java.lang.String data)This method is invoked from
browser.js
, from thewindow.WebSocket.send(data)
function.- Parameters:
data
- the data to send
-
close
public void close(int code, java.lang.String reason)This method is invoked from
browser.js
, from thewindow.WebSocket.close(code, reason)
function.- Parameters:
code
- the close codereason
- the close reason
-
onWebSocketConnect
public void onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session)- Specified by:
onWebSocketConnect
in interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onWebSocketBinary
public void onWebSocketBinary(byte[] payload, int offset, int len)- Specified by:
onWebSocketBinary
in interfaceorg.eclipse.jetty.websocket.api.WebSocketListener
-
onWebSocketText
public void onWebSocketText(java.lang.String data)- Specified by:
onWebSocketText
in interfaceorg.eclipse.jetty.websocket.api.WebSocketListener
-
onWebSocketClose
public void onWebSocketClose(int closeCode, java.lang.String reason)- Specified by:
onWebSocketClose
in interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onWebSocketError
public void onWebSocketError(java.lang.Throwable x)- Specified by:
onWebSocketError
in interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-