use of com.nabalive.server.jabber.packet.PingPacket in project NabAlive by jcheype.
the class ConnectionWelcome method onEvent.
@Override
public void onEvent(String sender, Event event) throws Exception {
logger.debug("event type {}", event.type);
logger.debug("event type {}", event.content);
if (event.type == Event.Type.UNBIND_RESOURCE && event.content.contains("<resource>boot</resource></unbind>")) {
Nabaztag nabaztag = nabaztagDAO.findOne("macAddress", sender);
logger.debug("WELCOME: unbind {}", nabaztag);
messageService.sendMessage(sender, new PingPacket(60));
if (nabaztag == null) {
logger.debug("WELCOME: SENDING SOUND");
String command = "CH http://www.nabalive.com/api/chor/rand/5\nMW\n" + "ST " + WELCOME_URL + "\nMW\n";
messageService.sendMessage(sender, command);
} else {
boolean isSleep = checkSleep(nabaztag);
logger.debug("WELCOME: ISSLEEP :" + isSleep);
if (isSleep) {
logger.debug("WELCOME: SENDING SLEEP");
messageService.sendMessage(nabaztag.getMacAddress(), new SleepPacket(SleepPacket.Action.Sleep));
}
}
}
}
Aggregations