Presentation Page

inma
2003-11-25
2004-05-18
  • inma
    inma
    2003-11-25

    Hello!!

       Does anybody know if cyberlink offers any presentation page handler or something similar in order to show the page for controlling the device? If not, what it would be the proper way to design and implement this functionality?

    Thanks very much in advance.

     
    • Tim Malcolm
      Tim Malcolm
      2003-11-25

      There is no "proper" design, but there are many good designs. When time permits, I intend to extend Cyberlink by adding an embedded Sevlet engine (no JSP). In the meantime, I use the following workaround:
      1. override Device.httpRequestReceived(HTTPRequest req)
      2. check the target URL
      3. IF it is the correct target
          3.1. handle request
      4. ELSE
          4.1 call super.httpRequestReceived

       
    • inma
      inma
      2003-11-28

      Hello!!
      I have more doubts about the presentation page. Once I have launched my device, how could I get the url and port where its web server is running? I think this could be useful in order to build the presentation page for that device.

      Thanks very much in advance.
      Cheers,
      Inma.

       
      • Tim Malcolm
        Tim Malcolm
        2003-11-28

        My advice is that you start looking at the source code, and do some experimentation to figure out what data is stored in the Device nodes. Here are a few methods that may be useful starting points:
          Device.getLocation()
          Device.getHttpPort()
          Device.getPresentationURL()
          Device.getURLBase()

         
    • Tim Malcolm
      Tim Malcolm
      2003-11-28

      Let me revise my previous posts with info I've just figured out: Cyberlink serves content from its root path, where the root path is the directory containing the device XML.

       
    • Satoshi Konno
      Satoshi Konno
      2003-12-18

      The Device class of CyberLink implements a HTTPRequestListner interface of org.cybergarage.http package to handle some HTTP requests from the control points. The HTTPRequestListener interface is bellow.

      public interface HTTPRequestListener
      {
      public void httpRequestRecieved(HTTPRequest httpReq);
      }

      To overide the interface, import the org.cybergarage.http and override the httpRequestRecieved method in your device that is a sub class of the Device class. The following example is a clock device using CyberLink, and adds the override method to return the presentation page.

      import org.cybergarage.http.*;

      public class ClockDevice extends Device implements ActionListener, QueryListener
      {
          .
          private final static String PRESENTATION_URI = "/presentation";
          public void httpRequestRecieved(HTTPRequest httpReq)
          {
              String uri = httpReq.getURI();
              if (uri.startsWith(PRESENTATION_URI) == false) {
                  super.httpRequestRecieved(httpReq);
                  return;
              }
              Clock clock = Clock.getInstance();
              String contents = "<HTML><BODY><H1>" + clock.toString() + "</H1></BODY></HTML>";
              HTTPResponse httpRes = new HTTPResponse();
              httpRes.setStatusCode(HTTPStatus.OK);
              httpRes.setContent(contents);
              httpReq.post(httpRes);
          }
      }

      I have uploaded the clock sample. Please check it :-)

      https://sourceforge.net/project/showfiles.php?group_id=75638

       
    • jan newmarch
      jan newmarch
      2004-05-18

      In the XML the presentation page is represented by a relative page (like other URLs). But when the client gets the device it _still_ is a relative URL, and you have to prefix it with Device.getURLBase() in order to get a well-formed remote URL that you can use. A control point shouldn't need to do this! Should this be fixed?

      Should I log this as a bug (two other bug fixes I suggested recently have been ignored so far...) But it's a cool piece of s/w anyway, thanks!