Package yapion.packet
Class YAPIONInputStream
- java.lang.Object
-
- yapion.packet.YAPIONInputStream
-
public final class YAPIONInputStream extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_WAITstatic intHIGH_WAITstatic intLOW_WAIT
-
Constructor Summary
Constructors Constructor Description YAPIONInputStream(java.io.InputStream inputStream)Creates a YAPIONInputStream from an InputStream.
-
Method Summary
Modifier and Type Method Description intavailable()Returns an estimate of bytes to be able to read.voidclose()Closes this InputStream and tries to close the handler ThreadYAPIONObjectread()Read and parses the next YAPIONObject.java.lang.ObjectreadObject()Read, parses and deserialized the next YAPIONObject.voidsetTypeReMapper(@NonNull TypeReMapper typeReMapper)Set aTypeReMapperto use for the deserialize call.voidsetYAPIONPacketReceiver(YAPIONPacketReceiver yapionPacketReceiver)Set a direct receiver for data from this InputStream.voidsetYAPIONPacketReceiver(YAPIONPacketReceiver yapionPacketReceiver, int time)Set a direct receiver for data from this InputStream.
-
-
-
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
-
-
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 aTypeReMapperto use for the deserialize call. This is useful to changePackage.toString()orClass.getTypeName()to another value.- Parameters:
typeReMapper- theTypeReMapperto use
-
available
public int available() throws java.io.IOExceptionReturns an estimate of bytes to be able to read.- Returns:
- the estimated byte count
- Throws:
java.io.IOException-YAPIONPacketReceivernot null orInputStream.available()
-
read
public YAPIONObject read() throws java.io.IOException
Read and parses the next YAPIONObject.- Returns:
- the next YAPIONObject
- Throws:
java.io.IOException-YAPIONPacketReceivernot null
-
readObject
public java.lang.Object readObject() throws java.io.IOExceptionRead, parses and deserialized the next YAPIONObject.- Returns:
- the next Object
- Throws:
java.io.IOException-YAPIONPacketReceivernot null
-
close
public void close() throws java.io.IOExceptionCloses this InputStream and tries to close the handler Thread- Throws:
java.io.IOException-InputStream.close()
-
-