Package jline.cli
Class LineServer
java.lang.Object
org.java_websocket.WebSocketAdapter
org.java_websocket.AbstractWebSocket
org.java_websocket.server.WebSocketServer
jline.cli.LineServer
- All Implemented Interfaces:
Runnable
,org.java_websocket.WebSocketListener
public class LineServer
extends org.java_websocket.server.WebSocketServer
LineServer 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/interfaces inherited from class org.java_websocket.server.WebSocketServer
org.java_websocket.server.WebSocketServer.WebSocketWorker
-
Field Summary
Fields inherited from class org.java_websocket.server.WebSocketServer
decoders
-
Constructor Summary
ConstructorDescriptionLineServer
(int port) Constructs a new LineServer instance on the specified port.LineServer
(String host, int port) Constructs a new LineServer instance on the specified host and port.LineServer
(InetSocketAddress address) Constructs a new LineServer instance with a specified address. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
The main method, which serves as the entry point for the server application.void
Called when a connection is closed.void
Called when an error occurs.void
Called when a message is received from a client.void
onMessage
(org.java_websocket.WebSocket conn, ByteBuffer message) Called when a binary message is received from a client.void
onOpen
(org.java_websocket.WebSocket conn, org.java_websocket.handshake.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, broadcast, broadcast, broadcast, broadcast, broadcast, createBuffer, getAddress, getConnections, getDraft, getLocalSocketAddress, getMaxPendingConnections, getPort, getRemoteSocketAddress, getWebSocketFactory, onCloseInitiated, onClosing, onConnect, onWebsocketClose, onWebsocketCloseInitiated, onWebsocketClosing, onWebsocketError, onWebsocketMessage, onWebsocketMessage, onWebsocketOpen, onWriteDemand, queue, releaseBuffers, removeConnection, run, setMaxPendingConnections, setWebSocketFactory, start, stop, 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
-
Field Details
-
message
-
-
Constructor Details
-
LineServer
public LineServer(int port) Constructs a new LineServer instance on the specified port.- Parameters:
port
- the port on which the server will listen.
-
LineServer
Constructs a new LineServer 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.
-
LineServer
Constructs a new LineServer instance with a specified address.- Parameters:
address
- the address on which the server will listen.
-
-
Method Details
-
main
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).
-
onOpen
public void onOpen(org.java_websocket.WebSocket conn, org.java_websocket.handshake.ClientHandshake handshake) Called when a new client connection is opened.- Specified by:
onOpen
in classorg.java_websocket.server.WebSocketServer
- Parameters:
conn
- the WebSocket connection.handshake
- the client handshake data.
-
onMessage
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.- Specified by:
onMessage
in classorg.java_websocket.server.WebSocketServer
- Parameters:
conn
- the WebSocket connection.message
- the message received from the client.
-
onMessage
Called when a binary message is received from a client. This method is currently a placeholder for future binary message processing.- Overrides:
onMessage
in classorg.java_websocket.server.WebSocketServer
- Parameters:
conn
- the WebSocket connection.message
- the binary message received from the client.
-
onClose
Called when a connection is closed.- Specified by:
onClose
in classorg.java_websocket.server.WebSocketServer
- 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
Called when an error occurs.- Specified by:
onError
in classorg.java_websocket.server.WebSocketServer
- Parameters:
conn
- the WebSocket connection.ex
- the exception that was thrown.
-
onStart
public void onStart()Called when the server is started. This method prints the server's address and port to the console.- Specified by:
onStart
in classorg.java_websocket.server.WebSocketServer
-