Package lu.kbra.p4j.socket.server
Class ServerClient
java.lang.Object
lu.kbra.p4j.socket.server.ServerClient
- All Implemented Interfaces:
Closeable,AutoCloseable,P4JInstance,P4JInstance.P4JClientInstance,P4JInstance.P4JServerClientInstance
Represents a P4JServer's client. This is a wrapper around a
SocketChannel that represents
a client connected to the server, on the server-side.-
Nested Class Summary
Nested classes/interfaces inherited from interface lu.kbra.p4j.socket.P4JInstance
P4JInstance.P4JClientInstance, P4JInstance.P4JClientServerInstance, P4JInstance.P4JServerClientInstance, P4JInstance.P4JServerInstance -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Consumer<P4JServerClientException> protected final P4JServerprotected ServerClientStatusprotected final SocketChannelprotected final UUID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the client socket.
Doesn't dispatch aP4JConnectionEvent.ClientDisconnectedEvent.voidDisconnects invalid input: '&' closes the client socket
And dispatches aP4JConnectionEvent.ClientDisconnectedEvent.final P4JEndPointgetUUID()voidread()protected voidreadHandleRawPacket(int id, ByteBuffer content) voidsetExceptionConsumer(Consumer<P4JServerClientException> exceptionConsumer) toString()booleanWrites a packet from the server to the client.
-
Field Details
-
serverClientStatus
-
uuid
-
server
-
socketChannel
-
exceptionConsumer
-
-
Constructor Details
-
ServerClient
-
-
Method Details
-
close
public void close()Closes the client socket.
Doesn't dispatch aP4JConnectionEvent.ClientDisconnectedEvent.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
P4JClientException- if the client socket is already closed or isn't started
-
disconnect
public void disconnect()Disconnects invalid input: '&' closes the client socket
And dispatches aP4JConnectionEvent.ClientDisconnectedEvent.- Throws:
P4JClientException- if the client socket is already closed or isn't started
-
getEndPoint
- Specified by:
getEndPointin interfaceP4JInstance- Specified by:
getEndPointin interfaceP4JInstance.P4JClientInstance- Specified by:
getEndPointin interfaceP4JInstance.P4JServerClientInstance
-
getExceptionConsumer
-
getServer
-
getServerClientStatus
-
getSocketChannel
-
getUUID
-
read
public void read() -
setExceptionConsumer
-
toString
-
write
Writes a packet from the server to the client.- Parameters:
packet- the packet to write to the client- Returns:
- If the packet was written successfully
-
readHandleRawPacket
-