Package io.hekate.network
Interface NetworkServerHandler<T>
-
- Type Parameters:
T
- Base type of messages that can be sent/received by this handler.
- All Known Implementing Classes:
GossipCommManager
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface NetworkServerHandler<T>
Handler for processing connections fromNetworkClient
s.This interface represents a server handler that can be registered within the
NetworkConnector
configuration in order to make it work as a server and be able to accept connections from remoteNetworkClient
s.For more details about connectors and networking please see the documentation of
NetworkService
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
onConnect(T login, NetworkEndpoint<T> client)
Called whenNetworkClient
connects to the server.default void
onDisconnect(NetworkEndpoint<T> client)
Called when client connection is closed.default void
onFailure(NetworkEndpoint<T> client, Throwable cause)
Called if error happened while communicating with the client.void
onMessage(NetworkMessage<T> msg, NetworkEndpoint<T> from)
Called when new message is received from the client.
-
-
-
Method Detail
-
onMessage
void onMessage(NetworkMessage<T> msg, NetworkEndpoint<T> from) throws IOException
Called when new message is received from the client.- Parameters:
msg
- Message.from
- Client connection.- Throws:
IOException
- Message handling error.
-
onConnect
default void onConnect(T login, NetworkEndpoint<T> client)
Called whenNetworkClient
connects to the server.- Parameters:
login
- Login message that was submitted by the client viaNetworkClient.connect(InetSocketAddress, Object, NetworkClientCallback)
method. If client haven't submitted any login message then this parameter will benull
.client
- Client connection.
-
onDisconnect
default void onDisconnect(NetworkEndpoint<T> client)
Called when client connection is closed.- Parameters:
client
- Client connection.
-
onFailure
default void onFailure(NetworkEndpoint<T> client, Throwable cause)
Called if error happened while communicating with the client.- Parameters:
client
- Client connection.cause
- Error.
-
-