Open dburnazyan opened 7 years ago
class BotSession has a method called isRunning(): boolean
https://github.com/rubenlagus/TelegramBots/blob/383b48cddd70af742782493d2e32d53f8fadcd4b/telegrambots-meta/src/main/java/org/telegram/telegrambots/generics/BotSession.java#L27
But this method returns true even if connection is lost
method run() of ReaderThread class looping until 'running' is true
running becomes false only when stop method of DefaultBotSession class is calling
So when telegram server is not accessible ReaderThread continues looping and just generates logs. But isRunning() still returns true because ReaderThread has't changed parameter 'running' to false
I suppose that there should be another method like 'isConnectionFine' or something like this and when httpclient request throws some exception while execution this method should return false.
The DefaultBotSession has a try-catch where the actual request is executed
We could add either just a boolean if that try-catch was sucessfull, add a callback if it didn't or make an enum with a few more statuses depending on why it failed.
I'd like to add a new "isConnectMethod" to return a boolean value about connection status, and won't set isrunning to false directly.
When I use Long Polling Bot I need to have possibility check if all work fine: is bot is connected to server or something goes wrong.