Package jline.cli

Class LineWebSocketServer

  • All Implemented Interfaces:
    java.lang.Runnable , org.java_websocket.WebSocketListener

    
    public class LineWebSocketServer
    extends WebSocketServer
                        

    LineWebSocketServer is a WebSocket server that receives client connections, processes incoming messages, and interacts with the LINE Solver. It handles both text and binary messages and can be started on a specified port or host and port.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static void main(Array<String> args) The main method, which serves as the entry point for the server application.
      void onClose(WebSocket conn, int code, String reason, boolean remote) Called when a connection is closed.
      void onError(WebSocket conn, Exception ex) Called when an error occurs.
      void onMessage(WebSocket conn, String message) Called when a message is received from a client.
      void onMessage(WebSocket conn, ByteBuffer message) Called when a binary message is received from a client.
      void onOpen(WebSocket conn, ClientHandshake handshake) Called when a new client connection is opened.
      void onStart() Called when the server is started.
      • Methods inherited from class org.java_websocket.server.WebSocketServer

        addConnection, allocateBuffers, broadcast, createBuffer, getAddress, getConnections, getDraft, getLocalSocketAddress, getMaxPendingConnections, getPort, getRemoteSocketAddress, getWebSocketFactory, onCloseInitiated, onClosing, onConnect, onWebsocketClose, onWebsocketCloseInitiated, onWebsocketClosing, onWebsocketError, onWebsocketMessage, onWebsocketOpen, onWriteDemand, queue, releaseBuffers, removeConnection, run, setMaxPendingConnections, setWebSocketFactory, start, stop
      • Methods inherited from class org.java_websocket.AbstractWebSocket

        getConnectionLostTimeout, isReuseAddr, isTcpNoDelay, setConnectionLostTimeout, setReuseAddr, setTcpNoDelay, startConnectionLostTimer, stopConnectionLostTimer
      • Methods inherited from class org.java_websocket.WebSocketAdapter

        onPreparePing, onWebsocketHandshakeReceivedAsClient, onWebsocketHandshakeReceivedAsServer, onWebsocketHandshakeSentAsClient, onWebsocketPing, onWebsocketPong
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LineWebSocketServer

        LineWebSocketServer(int port)
        Constructs a new LineWebSocketServer instance on the specified port.
        Parameters:
        port - the port on which the server will listen.
      • LineWebSocketServer

        LineWebSocketServer(String host, int port)
        Constructs a new LineWebSocketServer instance on the specified host and port.
        Parameters:
        host - the hostname or IP address on which the server will listen.
        port - the port on which the server will listen.
      • LineWebSocketServer

        LineWebSocketServer(InetSocketAddress address)
        Constructs a new LineWebSocketServer instance with a specified address.
        Parameters:
        address - the address on which the server will listen.
    • Method Detail

      • main

         static void main(Array<String> args)

        The main method, which serves as the entry point for the server application. It initializes and starts the server on a specified port.

        Parameters:
        args - command-line arguments (currently unused).
      • onClose

         void onClose(WebSocket conn, int code, String reason, boolean remote)

        Called when a connection is closed.

        Parameters:
        conn - the WebSocket connection.
        code - the status code indicating the reason for closure.
        reason - a textual description of the reason for closure.
        remote - indicates whether the connection was closed by the remote host.
      • onError

         void onError(WebSocket conn, Exception ex)

        Called when an error occurs.

        Parameters:
        conn - the WebSocket connection.
        ex - the exception that was thrown.
      • onMessage

         void onMessage(WebSocket conn, String message)

        Called when a message is received from a client. This method processes the message, saves the client data to a temporary file, and invokes the LINE Solver with the specified arguments.

        Parameters:
        conn - the WebSocket connection.
        message - the message received from the client.
      • onMessage

         void onMessage(WebSocket conn, ByteBuffer message)

        Called when a binary message is received from a client. This method is currently a placeholder for future binary message processing.

        Parameters:
        conn - the WebSocket connection.
        message - the binary message received from the client.
      • onOpen

         void onOpen(WebSocket conn, ClientHandshake handshake)

        Called when a new client connection is opened.

        Parameters:
        conn - the WebSocket connection.
        handshake - the client handshake data.
      • onStart

         void onStart()

        Called when the server is started. This method prints the server's address and port to the console.