javaatmosphere

Broadcast to only one client with Atmosphere


How do I broadcast messages from only one client to another with Atmosphere (Meteor)?I have currently this implementation based on meteor tutorial

@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));
}

Solution

  • Here is the Atmosphere FAQ on their wiki: https://github.com/Atmosphere/atmosphere/wiki/Creating-private-channel-of-communication-between-Browsers