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 Object
implements org.eclipse.jetty.websocket.api.WebSocketListener
This class is the underlying implementation of JavaScript's window.WebSocket in browser.js.
-
Constructor Summary
ConstructorsConstructorDescriptionWebSocketConnection(JavaScript javaScript, Object jsWebSocket, Object connector, String url, String protocol) This constructor is invoked frombrowser.js, from thewindow.WebSocketconstructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is invoked frombrowser.js, from thewindow.WebSocket.close(code, reason)function.voidonWebSocketBinary(byte[] payload, int offset, int len) voidonWebSocketClose(int closeCode, String reason) voidonWebSocketConnect(org.eclipse.jetty.websocket.api.Session session) voidvoidonWebSocketText(String data) voidThis method is invoked frombrowser.js, from thewindow.WebSocket.send(data)function.
-
Constructor Details
-
WebSocketConnection
public WebSocketConnection(JavaScript javaScript, Object jsWebSocket, Object connector, String url, String protocol) This constructor is invoked from
browser.js, from thewindow.WebSocketconstructor.- Parameters:
javaScript- the (java) JavaScript objectjsWebSocket- the (javascript) WebSocket object created inbrowser.jsconnector- 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
This method is invoked from
browser.js, from thewindow.WebSocket.send(data)function.- Parameters:
data- the data to send
-
close
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:
onWebSocketConnectin interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onWebSocketBinary
public void onWebSocketBinary(byte[] payload, int offset, int len) - Specified by:
onWebSocketBinaryin interfaceorg.eclipse.jetty.websocket.api.WebSocketListener
-
onWebSocketText
- Specified by:
onWebSocketTextin interfaceorg.eclipse.jetty.websocket.api.WebSocketListener
-
onWebSocketClose
- Specified by:
onWebSocketClosein interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onWebSocketError
- Specified by:
onWebSocketErrorin interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-