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 and Description |
---|
WebSocketConnection(JavaScript javaScript,
Object jsWebSocket,
Object connector,
String url,
String protocol)
This constructor is invoked from
browser.js ,
from the window.WebSocket constructor. |
Modifier and Type | Method and Description |
---|---|
void |
close(int code,
String reason)
This method is invoked from
browser.js ,
from the window.WebSocket.close(code, reason) function. |
void |
onWebSocketBinary(byte[] payload,
int offset,
int len) |
void |
onWebSocketClose(int closeCode,
String reason) |
void |
onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session) |
void |
onWebSocketError(Throwable x) |
void |
onWebSocketText(String data) |
void |
send(String data)
This method is invoked from
browser.js ,
from the window.WebSocket.send(data) function. |
public WebSocketConnection(JavaScript javaScript, Object jsWebSocket, Object connector, String url, String protocol)
This constructor is invoked from browser.js
,
from the window.WebSocket
constructor.
javaScript
- the (java) JavaScript objectjsWebSocket
- the (javascript) WebSocket object created in browser.js
connector
- the (java) WebSocketConnector objecturl
- the WebSocket URL passed to the window.WebSocket(url, protocol)
constructorprotocol
- the WebSocket protocol passed to the window.WebSocket(url, protocol)
constructorpublic void send(String data)
This method is invoked from browser.js
,
from the window.WebSocket.send(data)
function.
data
- the data to sendpublic void close(int code, String reason)
This method is invoked from browser.js
,
from the window.WebSocket.close(code, reason)
function.
code
- the close codereason
- the close reasonpublic void onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session)
onWebSocketConnect
in interface org.eclipse.jetty.websocket.api.WebSocketConnectionListener
public void onWebSocketBinary(byte[] payload, int offset, int len)
onWebSocketBinary
in interface org.eclipse.jetty.websocket.api.WebSocketListener
public void onWebSocketText(String data)
onWebSocketText
in interface org.eclipse.jetty.websocket.api.WebSocketListener
public void onWebSocketClose(int closeCode, String reason)
onWebSocketClose
in interface org.eclipse.jetty.websocket.api.WebSocketConnectionListener
public void onWebSocketError(Throwable x)
onWebSocketError
in interface org.eclipse.jetty.websocket.api.WebSocketConnectionListener
Copyright © 2008–2023 The CometD Project. All rights reserved.