This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Presence
Vrekt edited this page Jan 13, 2020
·
1 revision
The Presences
class is a wrapper for PresencePublicService
and the PresenceXMPPProvider
class provides presence XMPP support.
final var lastOnline = athena.presence().lastOnline();
lastOnline.toAccounts().forEach((account, instant) -> {
System.err.println("Account " + account.displayName() + " was last online " + instant.toString());
});
To subscribe/unsubscribe:
athena.presence().subscribe("accountId");
athena.presence().unsubscribe("accountId");
To get a list of subscriptions:
athena.presence().subscriptions().forEach(presenceSubscription -> {
System.err.println("Account " + presenceSubscription.accountId() + " subscribed at " + presenceSubscription.subscribedAt().toString());
});
You can broadcast to mobile users that you are playing Fortnite too. This can only be done every ~30 minutes.
athena.presence().broadcast();
You can change/get settings.
// get
final var settings = athena.presence().settings();
System.err.println(settings.enabled());
// set
athena.presence().setSettings(new SubscriptionSettings(false));
athena.presence().registerPresenceListener(presence -> {
if (presence.isPlayingFortnite()) {
// do something!
}
});
First, register your annotation/listener class.
athena.presence().registerEventListener(this);
Then,
@PresenceEvent
public void onPresence(FortnitePresence presence) {
if (presence.isPlayingFortnite()) {
// do something!
}
}
You can filter presences by account ID. Start by implementing PresenceFilter
and then:
athena.presence().useFilter(new MyFilter());
The filter will accept presences provided that its active, ready and relevant.
Example:
public class Example implements PresenceFilter {
@Override
public boolean ready() {
return isReady;
}
@Override
public boolean active() {
return true;
}
@Override
public boolean isRelevant(String accountId) {
return myList.contains(accountId);
}
@Override
public void consume(FortnitePresence presence) {
// do something.
}
}