Examples of Backyard


Examples of de.jochenbrissier.backyard.core.Backyard

    HttpServletRequest req = ev.getHttpServletRequest();
    HttpServletResponse resp = ev.getHttpServletResponse();

    // Backyard API

    Backyard backyard = new Backyard(req, resp);

    backyard.setServlet(this);

    // json obj
    String data = req.getParameter("data");

    try {
      log.debug("Parsing JSON: " + data);
      JSONObject json = new JSONObject(data);

      // get function from request json
      String function = json.getString("fn");

      if (function.matches("handshake")) {
        log.debug("Handshake");

        // TODO: GENERATE AN ID OR SEND THE SESSION ID TO THE CLIENT

        PrintWriter pw = ev.getHttpServletResponse().getWriter();

        resp.getWriter().print(
            "{\"status\":\"OK\",\"id\":\""
                + req.getSession().getId() + "\",\"websocket\":\""+Backyard.isWebsocketSupport()+"\"}");        pw.flush();
        pw.close();

        return;

      }

      if (function.matches("comet")) {
        log.debug("comet");

        // if the implementation is a non Tomcat implementation invoke
        // the normal
        if (req.getAttribute("de.jochenbrissier.byw.comet") != null
            && req.getAttribute("de.jochenbrissier.byw.comet")
                .equals("nonTomcat")) {
          backyard.startAsync();
        } else {
          backyard.startAsync(ev);
        }
      }

      if (function.matches("listen")) {
        log.debug("listen");
        listenChannel(req, resp, json, backyard);
        ev.close();
      }

      if (function.matches("send")) {

        log.debug("sendtochannel");

        JSONObject channeldata = json.getJSONObject("channel");

        try {

          backyard.getChannel(channeldata.getString("channel_name"))
              .sendMessage(json.getString("data"));

        } catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here

Examples of de.jochenbrissier.backyard.core.Backyard

  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    Backyard ba = new Backyard(req, resp);
    //ba.addMember();
    ba.listenToChannel("kein/plan");
   
 
   
   
    System.out.println(ba.getChannel("kein/plan").getMembers());
   
   
    System.out.println(ba.getChannel("kein/plan").isMember(req.getSession().getId()));
   
   
 
   
   
View Full Code Here

Examples of de.jochenbrissier.backyard.core.Backyard

    //tomcat character encoding fix ...
    resp.setCharacterEncoding(req.getCharacterEncoding());
   
   
    // Backyard API
    Backyard backyard = new Backyard(req, resp);

    backyard.setServlet(this);

    // json obj
    String data = req.getParameter("data");

    try {
      log.debug("Parsing JSON: " + data);
      JSONObject json = new JSONObject(data);

      // get function from request json
      String function = json.getString("fn");

      if (function.matches("handshake")) {
        log.debug("Handshake");

        // TODO: GENERATE AN ID OR SEND THE SESSION ID TO THE CLIENT

        PrintWriter pw = ev.getHttpServletResponse().getWriter();

        resp.getWriter().print(
            "{\"status\":\"OK\",\"id\":\""
                + req.getSession().getId()
                + "\",\"websocket\":\""
                + Backyard.isWebsocketSupport() + "\"}");
        pw.flush();
        pw.close();

        return;

      }

      if (function.matches("comet")) {
        log.debug("comet");

        // if the implementation is a non Tomcat implementation invoke
        // the normal
        if (req.getAttribute("de.jochenbrissier.byw.comet") != null
            && req.getAttribute("de.jochenbrissier.byw.comet")
                .equals("nonTomcat")) {
          backyard.startAsync();
        } else {
          backyard.startAsync(ev);
        }
      }

      if (function.matches("listen")) {
        log.debug("listen");
        listenChannel(req, resp, json, backyard);
        ev.close();
      }

      if (function.matches("send")) {

        log.debug("sendtochannel");

        JSONObject channeldata = json.getJSONObject("channel");

        try {

          backyard.getChannel(channeldata.getString("channel_name"))
              .sendMessage(json.getString("data"));

        } catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here

Examples of de.jochenbrissier.backyard.core.Backyard

    log.debug("enter BackyardServlet");

    // Backyard API

    Backyard backyard = new Backyard(req, resp);

    backyard.setServlet(this);

    // json obj
    String data = req.getParameter("data");

    try {
      log.debug("Parsing JSON: " + data);
      JSONObject json = new JSONObject(data);

      // get function from request json
      String function = json.getString("fn");

      if (function.matches("handshake")) {
        log.debug("Handshake");

        // TODO: GENERATE AN ID OR SEND THE SESSION ID TO THE CLIENT

        resp.getWriter().print(
            "{\"status\":\"OK\",\"id\":\""
                + req.getSession().getId() + "\",\"websocket\":\""+Backyard.isWebsocketSupport()+"\"}");

        return;

      }

      if (function.matches("comet")) {
        log.debug("comet");

        backyard.startAsync();

      }

      // if the json obj contains the function listen
      if (function.matches("listen")) {
        log.debug("listen");
        listenChannel(req, resp, json, backyard);
      }
      // if the json obj contains the function send

      if (function.matches("send")) {

        log.debug("sendtochannel");

        JSONObject channeldata = json.getJSONObject("channel");

        try {

          backyard.getChannel(channeldata.getString("channel_name"))
              .sendMessage(json.getString("data"));

        } catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here

Examples of de.jochenbrissier.backyard.core.Backyard

    HttpServletRequest req = ev.getHttpServletRequest();
    HttpServletResponse resp = ev.getHttpServletResponse();

    // Backyard API

    Backyard backyard = new Backyard(req, resp);

    backyard.setServlet(this);

    // json obj
    String data = req.getParameter("data");

    try {
      log.debug("Parsing JSON: " + data);
      JSONObject json = new JSONObject(data);

      // get function from request json
      String function = json.getString("fn");

      if (function.matches("handshake")) {
        log.debug("Handshake");

        // TODO: GENERATE AN ID OR SEND THE SESSION ID TO THE CLIENT

        PrintWriter pw = ev.getHttpServletResponse().getWriter();

        pw.print("{\"status\":\"OK\"}");
        pw.flush();
        pw.close();

        return;

      }

      if (function.matches("comet")) {
        log.debug("comet");

        // if the implementation is a non Tomcat implementation invoke
        // the normal
        if (req.getAttribute("de.jochenbrissier.byw.comet") != null
            && req.getAttribute("de.jochenbrissier.byw.comet")
                .equals("nonTomcat")) {
          backyard.startAsync();
        } else {
          backyard.startAsync(ev);
        }
      }

      if (function.matches("listen")) {
        log.debug("listen");
        listenChannel(req, resp, json, backyard);
        ev.close();
      }

      if (function.matches("send")) {

        log.debug("sendtochannel");

        JSONObject channeldata = json.getJSONObject("channel");

        try {

          backyard.getChannel(channeldata.getString("channel_name"))
              .sendMessage(json.getString("data"));

        } catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here

Examples of de.jochenbrissier.backyard.core.Backyard

   
   
    // Backyard API

    Backyard backyard = new Backyard(req, resp);
   

    backyard.setServlet(this);

 

    // json obj
    String data = req.getParameter("data");

    try {
      log.debug("Parsing JSON: " + data);
      JSONObject json = new JSONObject(data);

      // get function from request json
      String function = json.getString("fn");
     
     
      if (function.matches("handshake")) {
        log.debug("Handshake");

          //TODO: GENERATE AN ID OR SEND THE SESSION ID TO THE CLIENT
       
          resp.getWriter().print("{\"status\":\"OK\",\"id\":\""+req.getSession().getId()+"\"}");
       
       
         
        return;

      }
     
      if (function.matches("comet")) {
        log.debug("comet");

       
          backyard.startAsync();

      }
     
     
     
     
     
//if the json obj contains the function listen
      if (function.matches("listen")) {
        log.debug("listen");
        listenChannel(req, resp, json, backyard);
      }
      //if the json obj contains the function send

      if (function.matches("send")) {

        log.debug("sendtochannel");

        JSONObject channeldata = json.getJSONObject("channel");

        try {

          backyard.getChannel(channeldata.getString("channel_name"))
              .sendMessage(json.getString("data"));

        } catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here
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.