public final class UpdateReader
extends java.lang.Object
implements java.lang.AutoCloseable
| Constructor and Description |
|---|
UpdateReader(Bot bot)
Constructs an UpdateReader.
|
UpdateReader(Bot bot,
java.util.function.LongUnaryOperator backOff)
Constructs an UpdateReader.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns the number of updates that can be read from this update reader without blocking by the
next invocation read method for this update reader.
|
void |
close() |
void |
discardAll()
Discards buffered updates and all received updates.
|
int |
getUpdates()
Retrieves new updates received from the bot.
|
Update |
read()
Reads one update from the stream.
|
boolean |
ready()
Tells whether this stream is ready to be read.
|
public UpdateReader(Bot bot, java.util.function.LongUnaryOperator backOff)
bot - the bot that receive updatesbackOff - back off to be used when long polling failspublic UpdateReader(Bot bot)
bot - the bot that receive updatespublic int available()
Integer.MAX_VALUE, returns
Integer.MAX_VALUE.public boolean ready()
true if the next read() is guaranteed not to block for input,
false otherwise. Note that returning false does not guarantee that the
next read will block.public Update read() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException - if an I/O Exception occursjava.lang.InterruptedException - if any thread has interrupted the current
thread while waiting for updatespublic int getUpdates()
throws java.io.IOException
java.io.IOException - if an I/O Exception occurspublic void discardAll()
throws java.io.IOException
java.io.IOException - if an I/O Exception occurspublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseablejava.io.IOException