tags:

views:

5

answers:

0

I am working on an notification application using Cometd 2.1. I have a jQuery client that subscribes to my channel, and an authorizer that determines their user context. When they subscribe, I am making a subscription to Redis that may generate events in the future to send back to the client. The documentation says not to create specific channels for individual clients, so I am currently publisher the connections to a lookup table in my authenticator that maps sessions back to the user context. Then when I have a message, I do:

     Map<string, Set<ServerSession>> subscribers = clientMappings.get(event.getClientId());
     Set<ServerSession> destinations = subscribers.get(event.getTopic());    

     for (ServerSession session : destinations) {
         session.deliver(session, event.getTopic(), event.getMessage(), null);
     }

What I have not been able to determine is 1) if I am using the server API properly -- it does not seem like I have a from and to session 2) if there is a better way to do this. It seems that I am doing a lot of work to manage the sessions that the framework would provide.