本文整理了Java中org.jivesoftware.smack.util.Async
类的一些代码示例,展示了Async
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Async
类的具体详情如下:
包路径:org.jivesoftware.smack.util.Async
类名称:Async
暂无
代码示例来源:origin: igniterealtime/Smack
void setOwner(final BareJid owner) {
this.owner = owner;
Async.go(new Runnable() {
@Override
public void run() {
for (ThingStateChangeListener thingStateChangeListener : listeners) {
thingStateChangeListener.owned(owner);
}
}
});
}
代码示例来源:origin: igniterealtime/Smack
/**
* Creates a new thread with the given Runnable, marks it daemon, starts it and returns the started thread.
*
* @param runnable
* @return the started thread.
*/
public static Thread go(Runnable runnable) {
Thread thread = daemonThreadFrom(runnable);
thread.start();
return thread;
}
代码示例来源:origin: igniterealtime/Smack
@Override
public void processStanza(final Stanza packet) {
Async.go(new Runnable() {
@Override
public void run() {
try {
getOmemoService().onOmemoMessageStanzaReceived(packet,
new LoggedInOmemoManager(OmemoManager.this));
} catch (SmackException.NotLoggedInException e) {
LOGGER.warning("Received OMEMO stanza while being offline: " + e);
}
}
});
}
};
代码示例来源:origin: igniterealtime/Smack
/**
* Creates a new thread with the given Runnable, marks it daemon, sets the name, starts it and returns the started
* thread.
*
* @param runnable
* @param threadName the thread name.
* @return the started thread.
*/
public static Thread go(Runnable runnable, String threadName) {
Thread thread = daemonThreadFrom(runnable);
thread.setName(threadName);
thread.start();
return thread;
}
代码示例来源:origin: igniterealtime/Smack
@Override
public void onCarbonCopyReceived(final CarbonExtension.Direction direction,
final Message carbonCopy,
final Message wrappingMessage) {
Async.go(new Runnable() {
@Override
public void run() {
if (omemoMessageStanzaFilter.accept(carbonCopy)) {
try {
getOmemoService().onOmemoCarbonCopyReceived(direction, carbonCopy, wrappingMessage,
new LoggedInOmemoManager(OmemoManager.this));
} catch (SmackException.NotLoggedInException e) {
LOGGER.warning("Received OMEMO carbon copy while being offline: " + e);
}
}
}
});
}
};
代码示例来源:origin: org.igniterealtime.smack/smack-core
/**
* Creates a new thread with the given Runnable, marks it daemon, starts it and returns the started thread.
*
* @param runnable
* @return the started thread.
*/
public static Thread go(Runnable runnable) {
Thread thread = daemonThreadFrom(runnable);
thread.start();
return thread;
}
代码示例来源:origin: igniterealtime/Smack
/**
* Initialize the manager without blocking. Once the manager is successfully initialized, the finishedCallback will
* be notified. It will also get notified, if an error occurs.
*
* @param finishedCallback callback that gets called once the manager is initialized.
*/
public void initializeAsync(final InitializationFinishedCallback finishedCallback) {
Async.go(new Runnable() {
@Override
public void run() {
try {
initialize();
finishedCallback.initializationFinished(OmemoManager.this);
} catch (Exception e) {
finishedCallback.initializationFailed(e);
}
}
});
}
代码示例来源:origin: org.igniterealtime.smack/smack-core
/**
* Creates a new thread with the given Runnable, marks it daemon, sets the name, starts it and returns the started
* thread.
*
* @param runnable
* @param threadName the thread name.
* @return the started thread.
*/
public static Thread go(Runnable runnable, String threadName) {
Thread thread = daemonThreadFrom(runnable);
thread.setName(threadName);
thread.start();
return thread;
}
代码示例来源:origin: igniterealtime/Smack
@Override
public void newIncomingMessage(final EntityBareJid from, final Message message, Chat chat) {
Async.go(new Runnable() {
@Override
public void run() {
代码示例来源:origin: igniterealtime/Smack
/**
* Initializes the reader in order to be used. The reader is initialized during the
* first connection and when reconnecting due to an abruptly disconnection.
*/
void init() {
done = false;
Async.go(new Runnable() {
@Override
public void run() {
parsePackets();
}
}, "Smack Reader (" + getConnectionCounter() + ")");
}
代码示例来源:origin: igniterealtime/Smack
/**
* Starts a reconnection mechanism if it was configured to do that.
* The algorithm is been executed when the first connection error is detected.
*/
private synchronized void reconnect() {
XMPPConnection connection = this.weakRefConnection.get();
if (connection == null) {
LOGGER.fine("Connection is null, will not reconnect");
return;
}
// Since there is no thread running, creates a new one to attempt
// the reconnection.
// avoid to run duplicated reconnectionThread -- fd: 16/09/2010
if (reconnectionThread != null && reconnectionThread.isAlive())
return;
reconnectionThread = Async.go(reconnectionRunnable,
"Smack Reconnection Manager (" + connection.getConnectionCounter() + ')');
}
代码示例来源:origin: igniterealtime/Smack
if (mucs.isEmpty()) return;
Async.go(new Runnable() {
@Override
public void run() {
代码示例来源:origin: igniterealtime/Smack
@Override
public void eventReceived(final EntityBareJid from, final EventElement event, final Message message) {
if (PEP_NODE_PUBLIC_KEYS.equals(event.getEvent().getNode())) {
final BareJid contact = from.asBareJid();
LOGGER.log(Level.INFO, "Received OpenPGP metadata update from " + contact);
Async.go(new Runnable() {
@Override
public void run() {
ItemsExtension items = (ItemsExtension) event.getExtensions().get(0);
PayloadItem<?> payload = (PayloadItem) items.getItems().get(0);
PublicKeysListElement listElement = (PublicKeysListElement) payload.getPayload();
processPublicKeysListElement(from, listElement);
}
}, "ProcessOXMetadata");
}
}
};
代码示例来源:origin: igniterealtime/Smack
Async.go(new Runnable() {
@Override
public void run() {
代码示例来源:origin: igniterealtime/Smack
/**
* Initializes the writer in order to be used. It is called at the first connection and also
* is invoked if the connection is disconnected by an error.
*/
void init() {
shutdownDone.init();
shutdownTimestamp = null;
if (unacknowledgedStanzas != null) {
// It's possible that there are new stanzas in the writer queue that
// came in while we were disconnected but resumable, drain those into
// the unacknowledged queue so that they get resent now
drainWriterQueueToUnacknowledgedStanzas();
}
queue.start();
Async.go(new Runnable() {
@Override
public void run() {
writePackets();
}
}, "Smack Writer (" + getConnectionCounter() + ")");
}
代码示例来源:origin: igniterealtime/Smack
@Test(expected = TestException.class)
public void exceptionTestResultSyncPoint() throws Exception {
final CyclicBarrier barrier = new CyclicBarrier(2);
final ResultSyncPoint<String, TestException> rsp = new ResultSyncPoint<>();
Async.go(new Async.ThrowingRunnable() {
@Override
public void runOrThrow() throws InterruptedException, BrokenBarrierException {
barrier.await();
rsp.signal(new TestException());
}
});
barrier.await();
rsp.waitForResult(60 * 1000);
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void testResultSyncPoint() throws Exception {
final String result = "Hip Hip Hurrary!!111!";
final CyclicBarrier barrier = new CyclicBarrier(2);
final ResultSyncPoint<String, Exception> rsp = new ResultSyncPoint<>();
Async.go(new Async.ThrowingRunnable() {
@Override
public void runOrThrow() throws InterruptedException, BrokenBarrierException {
barrier.await();
rsp.signal(result);
}
});
barrier.await();
String receivedResult = rsp.waitForResult(60 * 1000);
assertEquals(result, receivedResult);
}
代码示例来源:origin: igniterealtime/Smack
" Received: " + Arrays.toString(receivedDeviceList.copyDeviceIds().toArray()) +
" Published: " + Arrays.toString(newDeviceList.copyDeviceIds().toArray()));
Async.go(new Runnable() {
@Override
public void run() {
代码示例来源:origin: org.igniterealtime.smack/smack-experimental
void setOwner(final BareJid owner) {
this.owner = owner;
Async.go(new Runnable() {
@Override
public void run() {
for (ThingStateChangeListener thingStateChangeListener : listeners) {
thingStateChangeListener.owned(owner);
}
}
});
}
代码示例来源:origin: org.igniterealtime.smack/smack-core
/**
* Starts a reconnection mechanism if it was configured to do that.
* The algorithm is been executed when the first connection error is detected.
*/
private synchronized void reconnect() {
XMPPConnection connection = this.weakRefConnection.get();
if (connection == null) {
LOGGER.fine("Connection is null, will not reconnect");
return;
}
// Since there is no thread running, creates a new one to attempt
// the reconnection.
// avoid to run duplicated reconnectionThread -- fd: 16/09/2010
if (reconnectionThread != null && reconnectionThread.isAlive())
return;
reconnectionThread = Async.go(reconnectionRunnable,
"Smack Reconnection Manager (" + connection.getConnectionCounter() + ')');
}
内容来源于网络,如有侵权,请联系作者删除!