1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 02:27:58 +01:00

Merge pull request #531 from Flowdalic/truely-async-sends

[core] Add AbstractXMPPConnection.TRUELY_ASYNC_SENDS
This commit is contained in:
Florian Schmaus 2022-06-06 10:01:28 +02:00 committed by GitHub
commit 382ec723a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 7 deletions

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2009 Jive Software, 2018-2020 Florian Schmaus.
* Copyright 2009 Jive Software, 2018-2022 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -2000,11 +2000,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}, timeout, TimeUnit.MILLISECONDS);
addAsyncStanzaListener(stanzaListener, replyFilter);
try {
sendStanza(stanza);
}
catch (NotConnectedException | InterruptedException exception) {
future.setException(exception);
Runnable sendOperation = () -> {
try {
sendStanza(stanza);
}
catch (NotConnectedException | InterruptedException exception) {
future.setException(exception);
}
};
if (SmackConfiguration.TRUELY_ASYNC_SENDS) {
Async.go(sendOperation);
} else {
sendOperation.run();
}
return future;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2018-2020 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 2018-2022 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -387,4 +387,14 @@ public final class SmackConfiguration {
}
}
}
/**
* If enabled, causes {@link AbstractXMPPConnection} to create a thread for every asynchronous send operation. This
* is meant to work-around a shortcoming of Smack 4.4, where certain send operations are not asynchronous even if
* they should be. This is an expert setting, do not toggle if you do not understand the consequences or have been
* told to do so. Note that it is expected that this will not be needed in future Smack versions.
*
* @since 4.4.6
*/
public static boolean TRUELY_ASYNC_SENDS = false;
}