Package org.buildndeploy.server

Source Code of org.buildndeploy.server.ConnectServlet

package org.buildndeploy.server;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.buildndeploy.server.model.ChannelConnection;
import org.buildndeploy.server.util.ChannelUtil;
import org.buildndeploy.server.util.ObjectifyUtil;
import org.buildndeploy.shared.model.MessageType;

@SuppressWarnings("serial")
public class ConnectServlet extends HttpServlet {
 
  private static Logger log = Logger.getLogger(ConnectServlet.class.getName());
 
  public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException {
    String clientId = ChannelUtil.parsePresence(req);
    // Have to query on indexed clientId property, should only be one result
    ChannelConnection s = ObjectifyUtil.ofy().load().type(ChannelConnection.class).id(clientId).get();
    s.setActive(true).save();
    String username = s.getUsername();
    ChannelUtil.pushMessage(username, MessageType.ConnectedEvent);
    log.info("User connected to Channel " + username);
  }

}
TOP

Related Classes of org.buildndeploy.server.ConnectServlet

TOP
Copyright © 2018 www.massapi.com. 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.