Package yapion.packet
Class YAPIONPacketStream
- java.lang.Object
-
- yapion.packet.YAPIONPacketStream
-
public final class YAPIONPacketStream extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_WAIT
static int
HIGH_WAIT
static int
LOW_WAIT
-
Constructor Summary
Constructors Constructor Description YAPIONPacketStream(YAPIONInputStream yapionInputStream, YAPIONOutputStream yapionOutputStream)
YAPIONPacketStream(YAPIONSocket yapionSocket)
-
Method Summary
Modifier and Type Method Description void
close()
void
setHeartBeatMode(HeartBeatType heartBeatMode, long heartBeatTimeOut)
Set the heartBeat mode desired for this connection.void
setTypeReMapper(@NonNull TypeReMapper typeReMapper)
Set aTypeReMapper
to use for the deserialize call.void
setYAPIONPacketReceiver(YAPIONPacketReceiver yapionPacketReceiver)
Set a direct receiver for data from this InputStream.void
setYAPIONPacketReceiver(YAPIONPacketReceiver yapionPacketReceiver, int time)
Set a direct receiver for data from this InputStream.void
write(YAPIONPacket yapionPacket)
-
-
-
Field Detail
-
DEFAULT_WAIT
public static final int DEFAULT_WAIT
- See Also:
- Constant Field Values
-
LOW_WAIT
public static final int LOW_WAIT
- See Also:
- Constant Field Values
-
HIGH_WAIT
public static final int HIGH_WAIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
YAPIONPacketStream
public YAPIONPacketStream(YAPIONSocket yapionSocket)
-
YAPIONPacketStream
public YAPIONPacketStream(YAPIONInputStream yapionInputStream, YAPIONOutputStream yapionOutputStream)
-
-
Method Detail
-
setYAPIONPacketReceiver
public void setYAPIONPacketReceiver(YAPIONPacketReceiver yapionPacketReceiver)
Set a direct receiver for data from this InputStream. If an exception was thrown while reading, parsing, or handling the received Packet an Exception packet will be raised and handled by the same YAPIONPacketReceiver.- Parameters:
yapionPacketReceiver
- the receiver
-
setYAPIONPacketReceiver
public void setYAPIONPacketReceiver(YAPIONPacketReceiver yapionPacketReceiver, int time)
Set a direct receiver for data from this InputStream. If an exception was thrown while reading, parsing, or handling the received Packet an Exception packet will be raised and handled by the same YAPIONPacketReceiver.- Parameters:
yapionPacketReceiver
- the receivertime
- the wait time of the internal receiver loop this time should be between 1 and 1000 ms and will be bounded to a value between it when outside values are given if -1 is given the default will be selected
-
setTypeReMapper
public void setTypeReMapper(@NonNull @NonNull TypeReMapper typeReMapper)
Set aTypeReMapper
to use for the deserialize call. This is useful to changePackage.toString()
orClass.getTypeName()
to another value.- Parameters:
typeReMapper
- theTypeReMapper
to use
-
setHeartBeatMode
public void setHeartBeatMode(HeartBeatType heartBeatMode, long heartBeatTimeOut)
Set the heartBeat mode desired for this connection. This takes effect when you callsetYAPIONPacketReceiver(YAPIONPacketReceiver)
orsetYAPIONPacketReceiver(YAPIONPacketReceiver, int)
.- Parameters:
heartBeatMode
- the specific mode to useheartBeatTimeOut
- if 'heartBeatMode' is eitherHeartBeatType.RECEIVE
orHeartBeatType.SEND_AND_RECEIVE
and no heartbeat packet was received for this amount of milliseconds the LostHeartBeatHandler gets called
-
close
public void close() throws java.io.IOException
- Throws:
java.io.IOException
-
write
public void write(YAPIONPacket yapionPacket)
-
-