Class 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 Detail

      • WebSocketConnection

        public WebSocketConnection​(JavaScript javaScript,
                                   Object jsWebSocket,
                                   Object connector,
                                   String url,
                                   String protocol)

        This constructor is invoked from browser.js, from the window.WebSocket constructor.

        Parameters:
        javaScript - the (java) JavaScript object
        jsWebSocket - the (javascript) WebSocket object created in browser.js
        connector - the (java) WebSocketConnector object
        url - the WebSocket URL passed to the window.WebSocket(url, protocol) constructor
        protocol - the WebSocket protocol passed to the window.WebSocket(url, protocol) constructor
    • Method Detail

      • send

        public void send​(String data)

        This method is invoked from browser.js, from the window.WebSocket.send(data) function.

        Parameters:
        data - the data to send
      • close

        public void close​(int code,
                          String reason)

        This method is invoked from browser.js, from the window.WebSocket.close(code, reason) function.

        Parameters:
        code - the close code
        reason - the close reason
      • onWebSocketConnect

        public void onWebSocketConnect​(org.eclipse.jetty.websocket.api.Session session)
        Specified by:
        onWebSocketConnect in interface org.eclipse.jetty.websocket.api.WebSocketConnectionListener
      • onWebSocketBinary

        public void onWebSocketBinary​(byte[] payload,
                                      int offset,
                                      int len)
        Specified by:
        onWebSocketBinary in interface org.eclipse.jetty.websocket.api.WebSocketListener
      • onWebSocketText

        public void onWebSocketText​(String data)
        Specified by:
        onWebSocketText in interface org.eclipse.jetty.websocket.api.WebSocketListener
      • onWebSocketClose

        public void onWebSocketClose​(int closeCode,
                                     String reason)
        Specified by:
        onWebSocketClose in interface org.eclipse.jetty.websocket.api.WebSocketConnectionListener
      • onWebSocketError

        public void onWebSocketError​(Throwable x)
        Specified by:
        onWebSocketError in interface org.eclipse.jetty.websocket.api.WebSocketConnectionListener