Package yapion.packet
Interface YAPIONPacketHandler
-
- 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 YAPIONPacketHandler
-
-
Method Summary
Modifier and Type Method Description static boolean
close(@NonNull YAPIONPacket yapionPacket)
Close an OutputStream associated with this YAPIONPacket.default boolean
closeOnException()
Specifies if the OutputStream and InputStream should be closed if an exception gets thrown.static YAPIONPacketHandler
createInstance(java.util.function.Consumer<YAPIONPacket> yapionPacketConsumer, boolean runThread, boolean ignoreException)
Create aYAPIONPacketHandler
by the different parametersstatic YAPIONPacketHandler
createInstance(java.util.function.Consumer<YAPIONPacket> yapionPacketConsumer, boolean runThread, boolean daemonThread, boolean ignoreException)
Create aYAPIONPacketHandler
by the different parametersdefault boolean
daemonThread()
Specifies if the Thread should be a Daemon or not.void
handlePacket(YAPIONPacket yapionPacket)
Handle a specificYAPIONPacket
.default boolean
ignoreException()
Specifies if exceptions should be ignores and not processes by the '@exception' handler.default boolean
runThread()
Specifies if this handler should be run in a Thread.
-
-
-
Method Detail
-
handlePacket
void handlePacket(YAPIONPacket yapionPacket)
Handle a specificYAPIONPacket
.- Parameters:
yapionPacket
- the packet to handle.
-
runThread
default boolean runThread()
Specifies if this handler should be run in a Thread.- Returns:
true
if it should run in a thread,false
otherwise
-
daemonThread
default boolean daemonThread()
Specifies if the Thread should be a Daemon or not. This only takes effect whenrunThread()
returnstrue
. If not implemented this method returnstrue
by default.- Returns:
true
if it should run as a daemon,false
otherwise.
-
ignoreException
default boolean ignoreException()
Specifies if exceptions should be ignores and not processes by the '@exception' handler.- Returns:
true
if exceptions should be ignored,false
otherwise
-
closeOnException
default boolean closeOnException()
Specifies if the OutputStream and InputStream should be closed if an exception gets thrown. This will be evaluated beforeignoreException()
is evaluated and will only take effect if used in conjunction with YAPIONSocket.- Returns:
true
if it should get closed on exception,false
otherwise
-
close
static boolean close(@NonNull @NonNull YAPIONPacket yapionPacket)
Close an OutputStream associated with this YAPIONPacket.- Parameters:
yapionPacket
- the packet to use- Returns:
true
if and only if the close was successful,false
otherwise
-
createInstance
static YAPIONPacketHandler createInstance(java.util.function.Consumer<YAPIONPacket> yapionPacketConsumer, boolean runThread, boolean daemonThread, boolean ignoreException)
Create aYAPIONPacketHandler
by the different parameters- Parameters:
yapionPacketConsumer
- theConsumer
to handle theYAPIONPacket
runThread
-true
if it should run in a thread,false
otherwisedaemonThread
-true
if it should run as a daemon,false
otherwise.ignoreException
-true
if exceptions should be ignored,false
otherwise- Returns:
YAPIONPacketHandler
instance
-
createInstance
static YAPIONPacketHandler createInstance(java.util.function.Consumer<YAPIONPacket> yapionPacketConsumer, boolean runThread, boolean ignoreException)
Create aYAPIONPacketHandler
by the different parameters- Parameters:
yapionPacketConsumer
- theConsumer
to handle theYAPIONPacket
runThread
-true
if it should run in a thread,false
otherwiseignoreException
-true
if exceptions should be ignored,false
otherwise- Returns:
YAPIONPacketHandler
instance
-
-