Package com.nabalive.data.core.model

Examples of com.nabalive.data.core.model.TmpData


                        ChannelBuffer content = request.request.getContent();
                        logger.debug("record orig size: {}", content.readableBytes());
                        ChannelBufferInputStream inputStream = new ChannelBufferInputStream(content);

                        TmpData sound = new TmpData();
                        sound.setData(ByteStreams.toByteArray(inputStream));
                        tmpDataDAO.save(sound, WriteConcern.SAFE);


                        String host = request.request.getHeader("Host");
                        String url = "http://" + host + "/record/" + sound.getId().toString();
                        logger.debug("sound url: {}", url);

                        final String command = "ST " + url + "\nMW\n";

                        Query<Nabaztag> query = nabaztagDAO.createQuery();
                        query.filter("subscribe.objectId", nabaztag.getId().toString());
                        List<Nabaztag> nabaztags = nabaztagDAO.find(query).asList();


                        logger.debug("sending to {} subscribers", nabaztags.size());
                        for (Nabaztag nab : nabaztags) {
                            if (connectionManager.containsKey(nab.getMacAddress())) {
                                final Nabaztag nabTmp = nab;
                                Runnable runnable = new Runnable() {
                                    @Override
                                    public void run() {
                                        logger.debug("sending to {}", nabTmp.getMacAddress());
                                        logger.debug("command {}", command);
                                        messageService.sendMessage(nabTmp.getMacAddress(), command);
                                    }
                                };
                                ses.schedule(runnable, 500, TimeUnit.MILLISECONDS);
                            }
                        }
                        response.write("ok");
                    }
                })
                .get(new Route("/record/:recordId") {
                    @Override
                    public void handle(Request request, Response response, Map<String, String> map) throws Exception {
                        ObjectId recordId = new ObjectId(checkNotNull(map.get("recordId")));

                        TmpData sound = checkNotNull(tmpDataDAO.get(recordId));

                        response.write(sound.getData());
                    }
                });
    }
View Full Code Here

TOP

Related Classes of com.nabalive.data.core.model.TmpData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.