Package jline.cli
Class LineWebSocketServer
java.lang.Object
org.java_websocket.WebSocketAdapter
org.java_websocket.AbstractWebSocket
org.java_websocket.server.WebSocketServer
jline.cli.LineWebSocketServer
- All Implemented Interfaces:
Runnable,org.java_websocket.WebSocketListener
public class LineWebSocketServer
extends org.java_websocket.server.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/interfaces inherited from class org.java_websocket.server.WebSocketServer
org.java_websocket.server.WebSocketServer.WebSocketWorker -
Field Summary
FieldsFields inherited from class org.java_websocket.server.WebSocketServer
decoders -
Constructor Summary
ConstructorsConstructorDescriptionLineWebSocketServer(int port) Constructs a new LineWebSocketServer instance on the specified port.LineWebSocketServer(String host, int port) Constructs a new LineWebSocketServer instance on the specified host and port.LineWebSocketServer(InetSocketAddress address) Constructs a new LineWebSocketServer instance with a specified address. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidThe main method, which serves as the entry point for the server application.voidCalled when a connection is closed.voidCalled when an error occurs.voidCalled when a message is received from a client.voidonMessage(org.java_websocket.WebSocket conn, ByteBuffer message) Called when a binary message is received from a client.voidonOpen(org.java_websocket.WebSocket conn, org.java_websocket.handshake.ClientHandshake handshake) Called when a new client connection is opened.voidonStart()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, stopMethods inherited from class org.java_websocket.AbstractWebSocket
getConnectionLostTimeout, isReuseAddr, isTcpNoDelay, setConnectionLostTimeout, setReuseAddr, setTcpNoDelay, startConnectionLostTimer, stopConnectionLostTimerMethods inherited from class org.java_websocket.WebSocketAdapter
onPreparePing, onWebsocketHandshakeReceivedAsClient, onWebsocketHandshakeReceivedAsServer, onWebsocketHandshakeSentAsClient, onWebsocketPing, onWebsocketPong
-
Field Details
-
message
-
-
Constructor Details
-
LineWebSocketServer
public LineWebSocketServer(int port) Constructs a new LineWebSocketServer instance on the specified port.- Parameters:
port- the port on which the server will listen.
-
LineWebSocketServer
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
Constructs a new LineWebSocketServer 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).
-
onClose
Called when a connection is closed.- Specified by:
onClosein 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:
onErrorin classorg.java_websocket.server.WebSocketServer- Parameters:
conn- the WebSocket connection.ex- the exception that was thrown.
-
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:
onMessagein 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:
onMessagein classorg.java_websocket.server.WebSocketServer- Parameters:
conn- the WebSocket connection.message- the binary message received from the client.
-
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:
onOpenin classorg.java_websocket.server.WebSocketServer- Parameters:
conn- the WebSocket connection.handshake- the client handshake data.
-
onStart
public void onStart()Called when the server is started. This method prints the server's address and port to the console.- Specified by:
onStartin classorg.java_websocket.server.WebSocketServer
-