Transfer to only one customer with atmosphere

How to transfer messages from one client to another using Atmosphere (Meteor)? I am currently using this implementation based on a meteorology textbook

@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
    Meteor.build(req).addListener(new AtmosphereResourceEventListenerAdapter());
}

@Override
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException {
    String body = req.getReader().readLine().trim();
    //some DAO lookups - here I would like to say I want to broadcast only to concrete client
    BroadcasterFactory.getDefault().lookup(DefaultBroadcaster.class, "/*").broadcast(UserDAO.getInstance().getUser(name));
}

I know this may be a stupid question, but I did not find any information about this topic, so I ask here :) Thanks for any advice.

+5
source share
3 answers

Another solution that I consider: to address only one client you do not need to broadcast, you can just do this:

     try
     {
        r.getResponse().write(message);
     }
     catch(IllegalStateException e)
     {
        logger.error("Could not send message through atmosphere " + userId);
     }

r - , .

+3
BroadcasterFactory.getDefault().lookup(atmosphereResource.uuid()).broadcast('something');
0

All Articles