mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
pep: improve API, add PepEventListener
The geoloc, mood and usertune PEP users showed a pattern. Instead of repeating this pattern every time, let PepManager do the hard work
This commit is contained in:
parent
7c2f9e3603
commit
340bcb2d12
11 changed files with 178 additions and 204 deletions
|
@ -25,9 +25,9 @@ import org.jivesoftware.smack.SmackException.NotLoggedInException;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
||||
import org.jivesoftware.smackx.geoloc.GeoLocationListener;
|
||||
import org.jivesoftware.smackx.geoloc.GeoLocationManager;
|
||||
import org.jivesoftware.smackx.geoloc.packet.GeoLocation;
|
||||
import org.jivesoftware.smackx.pep.PepEventListener;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
|
@ -79,10 +79,10 @@ public class GeolocationIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
|
||||
IntegrationTestRosterUtil.ensureBothAccountsAreSubscribedToEachOther(conOne, conTwo, timeout);
|
||||
final SimpleResultSyncPoint geoLocationReceived = new SimpleResultSyncPoint();
|
||||
final GeoLocationListener geoLocationListener = new GeoLocationListener() {
|
||||
final PepEventListener<GeoLocation> geoLocationListener = new PepEventListener<GeoLocation>() {
|
||||
|
||||
@Override
|
||||
public void onGeoLocationUpdated(EntityBareJid jid, GeoLocation geoLocation, Message message) {
|
||||
public void onPepEvent(EntityBareJid jid, GeoLocation geoLocation, String id, Message message) {
|
||||
if (geoLocation.equals(geoLocation1)) {
|
||||
geoLocationReceived.signal();
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class GeolocationIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
glm2.addGeoLocationListener(geoLocationListener);
|
||||
|
||||
try {
|
||||
glm1.sendGeolocation(geoLocation1);
|
||||
glm1.publishGeoLocation(geoLocation1);
|
||||
geoLocationReceived.waitForResult(timeout);
|
||||
} finally {
|
||||
glm2.removeGeoLocationListener(geoLocationListener);
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.jivesoftware.smackx.mood;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
||||
import org.jivesoftware.smackx.mood.element.MoodElement;
|
||||
import org.jivesoftware.smackx.pep.PepEventListener;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
import org.igniterealtime.smack.inttest.annotations.AfterClass;
|
||||
|
@ -43,7 +46,7 @@ public class MoodIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
|
||||
final SimpleResultSyncPoint moodReceived = new SimpleResultSyncPoint();
|
||||
|
||||
final MoodListener moodListener = (jid, moodElement, message) -> {
|
||||
final PepEventListener<MoodElement> moodListener = (jid, moodElement, id, message) -> {
|
||||
if (moodElement.getMood() == Mood.satisfied) {
|
||||
moodReceived.signal();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.jivesoftware.smack.SmackException.NotLoggedInException;
|
|||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
||||
import org.jivesoftware.smackx.pep.PepEventListener;
|
||||
import org.jivesoftware.smackx.usertune.element.UserTuneElement;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest;
|
||||
|
@ -61,9 +62,9 @@ public class UserTuneIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
|
||||
final SimpleResultSyncPoint userTuneReceived = new SimpleResultSyncPoint();
|
||||
|
||||
final UserTuneListener userTuneListener = new UserTuneListener() {
|
||||
final PepEventListener<UserTuneElement> userTuneListener = new PepEventListener<UserTuneElement>() {
|
||||
@Override
|
||||
public void onUserTuneUpdated(EntityBareJid jid, UserTuneElement userTuneElement, Message message) {
|
||||
public void onPepEvent(EntityBareJid jid, UserTuneElement userTuneElement, String id, Message message) {
|
||||
if (userTuneElement.equals(userTuneElement1)) {
|
||||
userTuneReceived.signal();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue