@Override
public void handle(Request request, Response response, Map<String, String> map) throws Exception {
String apikey = checkNotNull(map.get("apikey"));
Nabaztag nabaztag = checkNotNull(nabaztagDAO.findOne("apikey", apikey));
messageService.sendMessage(nabaztag.getMacAddress(), new SleepPacket(SleepPacket.Action.Sleep));
response.writeJSON("ok");
}
})
.get(new Route("/nabaztags/:apikey/wakeup") {
@Override
public void handle(Request request, Response response, Map<String, String> map) throws Exception {
String apikey = checkNotNull(map.get("apikey"));
Nabaztag nabaztag = checkNotNull(nabaztagDAO.findOne("apikey", apikey));
messageService.sendMessage(nabaztag.getMacAddress(), new SleepPacket(SleepPacket.Action.WakeUp));
response.writeJSON("ok");
}
})
.get(new Route("/nabaztags/:apikey/tz") {
@Override