use of com.nabalive.server.jabber.Status in project NabAlive by jcheype.
the class ApplicationScheduler method clock.
@Scheduled(cron = "0 0 * * * *")
public void clock() {
logger.debug("clock trigger");
// clock
Application application = checkNotNull(applicationManager.getApplication(CLOCK_APIKEY));
Query<Nabaztag> query = nabaztagDAO.createQuery().filter("applicationConfigList.applicationStoreApikey", CLOCK_APIKEY);
Iterator<Nabaztag> iterator = nabaztagDAO.find(query).iterator();
while (iterator.hasNext()) {
Nabaztag nabaztag = iterator.next();
Status status = connectionManager.get(nabaztag.getMacAddress());
if (status != null && !status.isAsleep()) {
try {
application.onStartup(nabaztag, findConfig(CLOCK_APIKEY, nabaztag.getApplicationConfigList()));
} catch (Exception e) {
logger.debug("cannot send message", e);
}
}
}
}
use of com.nabalive.server.jabber.Status in project NabAlive by jcheype.
the class ApplicationScheduler method mood.
@Scheduled(fixedDelay = 300000)
public void mood() {
logger.debug("mood trigger");
// mood
Application application = checkNotNull(applicationManager.getApplication(MOOD_APIKEY));
Query<Nabaztag> query = nabaztagDAO.createQuery().filter("applicationConfigList.applicationStoreApikey", MOOD_APIKEY);
Iterator<Nabaztag> iterator = nabaztagDAO.find(query).iterator();
while (iterator.hasNext()) {
Nabaztag nabaztag = iterator.next();
Status status = connectionManager.get(nabaztag.getMacAddress());
if (status != null && status.isIdle()) {
if (rand.nextInt(4) == 0) {
try {
application.onStartup(nabaztag, findConfig(MOOD_APIKEY, nabaztag.getApplicationConfigList()));
} catch (Exception e) {
logger.debug("cannot send message", e);
}
}
}
}
}
use of com.nabalive.server.jabber.Status in project NabAlive by jcheype.
the class ApplicationScheduler method taichi.
@Scheduled(fixedDelay = 400000)
public void taichi() {
logger.debug("taichi trigger");
// taichi
Application application = checkNotNull(applicationManager.getApplication(TAICHI_APIKEY));
Query<Nabaztag> query = nabaztagDAO.createQuery().filter("applicationConfigList.applicationStoreApikey", TAICHI_APIKEY);
Iterator<Nabaztag> iterator = nabaztagDAO.find(query).iterator();
while (iterator.hasNext()) {
Nabaztag nabaztag = iterator.next();
Status status = connectionManager.get(nabaztag.getMacAddress());
if (status != null && status.isIdle()) {
if (rand.nextInt(4) == 0) {
try {
application.onStartup(nabaztag, findConfig(TAICHI_APIKEY, nabaztag.getApplicationConfigList()));
} catch (Exception e) {
logger.debug("cannot send message", e);
}
}
}
}
}
use of com.nabalive.server.jabber.Status in project NabAlive by jcheype.
the class BaseEventRegistrationService method register.
@Override
public void register(String id, EventListener eventListener) {
Status status = connectionManager.get(id);
if (status == null) {
throw new IllegalArgumentException("id [" + id + "] is not found");
}
status.registerEvent(eventListener);
}
use of com.nabalive.server.jabber.Status in project NabAlive by jcheype.
the class BaseMessageService method sendMessage.
@Override
public void sendMessage(String to, Packet message) {
Status status = checkNotNull(connectionManager.get(to));
String xmpp = message.getXmpp("www.nabalive.server.jabber", status.getJid().toString());
status.write(xmpp);
}
Aggregations