Class WebSocketConnectionServer

    • Field Detail

      • websocket

        protected fi.iki.elonen.NanoWSD.WebSocket websocket
        The web socket.
      • socket

        protected java.net.Socket socket
        The low-level socket.
    • Constructor Detail

      • WebSocketConnectionServer

        public WebSocketConnectionServer​(fi.iki.elonen.NanoHTTPD.IHTTPSession handshakerequest,
                                         ITransportHandler<IWebSocketConnection> handlr,
                                         java.net.Socket acceptsocket)
        Creates the websocket.
    • Method Detail

      • sendMessage

        public IFuture<java.lang.Integer> sendMessage​(byte[] header,
                                                      byte[] body)
        Send bytes using the connection.
        Parameters:
        header - The message header.
        body - The message body.
        Returns:
        A future indicating success.
      • close

        public void close()
        Closes the connection (ignored if already closed).
      • forceClose

        public void forceClose()
        Forcibly closes the connection (ignored if already closed).
      • getWebSocket

        public fi.iki.elonen.NanoWSD.WebSocket getWebSocket()
        Returns the raw server web socket.
        Returns:
        The raw server web socket.
      • sendAsFrames

        protected void sendAsFrames​(byte[] data)
                             throws java.io.IOException
        Fragment and send data as websocket frames.
        Parameters:
        data - The data.
        Throws:
        java.io.IOException - On communication failure.