Exemplo n.º 1
0
 private void sendConnectionToContacts(Iterator<User> contacts, String email) {
   while (contacts.hasNext()) {
     User user = contacts.next();
     if (user.isConnected)
       ChannelApiHelper.sendMessage(
           user.getEmail(),
           ChannelApiHelper.encodeMessage(
               new ChApiChatUserConnected(Key.create(User.class, email))));
   }
 }
Exemplo n.º 2
0
 @Override
 public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
   ChannelService channelService = ChannelServiceFactory.getChannelService();
   ChannelPresence presence = channelService.parsePresence(request);
   Objectify ofy = ObjectifyService.begin();
   User user;
   try {
     // System.out.println(presence.clientId() + " connected");
     user =
         UserHelper.getUserWithEmail(ChannelApiHelper.getUserForAppkey(presence.clientId()), ofy);
   } catch (Exception e) {
     return;
   }
   user.isConnected = true;
   ofy.put(user);
   sendConnectionToContacts(ofy.get(user.getContacts()).values().iterator(), user.getEmail());
 }