mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-07 13:41:08 +01:00
Ensure that connection is authenticated in PingManager
This commit is contained in:
parent
50e068b6a7
commit
7521ef951a
2 changed files with 51 additions and 20 deletions
|
|
@ -177,9 +177,15 @@ public class PingManager extends Manager {
|
|||
* @throws NotConnectedException
|
||||
*/
|
||||
public boolean ping(String jid, long pingTimeout) throws NotConnectedException, NoResponseException {
|
||||
final XMPPConnection connection = connection();
|
||||
// Packet collector for IQs needs an connection that was at least authenticated once,
|
||||
// otherwise the client JID will be null causing an NPE
|
||||
if (!connection.isAuthenticated()) {
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
Ping ping = new Ping(jid);
|
||||
try {
|
||||
connection().createPacketCollectorAndSend(ping).nextResultOrThrow(pingTimeout);
|
||||
connection.createPacketCollectorAndSend(ping).nextResultOrThrow(pingTimeout);
|
||||
}
|
||||
catch (XMPPException exc) {
|
||||
return jid.equals(connection().getServiceName());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue