Ejemplo n.º 1
0
  /** Push Event to client. */
  public void push(Event anEvent) throws IOException {
    Log.debug("BCA event=" + anEvent.toXML());

    // Check if we should refresh
    if (anEvent.getEventType().equals(Protocol.E_REFRESH)) {
      // Append refresh and tail of HTML document
      // Construct the JS callback line to be sent as last line of doc.
      // This will refresh the request using the unique id to determine
      // the subscriber instance on the server. The client will wait for
      // a number of milliseconds.
      long refreshWaitMillis = Long.parseLong(anEvent.getField(P_WAIT));

      // Create servlet request for requesting next events (refresh)
      String url = anEvent.getField(P_URL);
      String jsRefreshTrigger =
          "\n<script language=\"JavaScript\">url=\'"
              + url
              + "\';\n setTimeout(\"refresh()\", "
              + refreshWaitMillis
              + ");\n</script>";

      send(jsRefreshTrigger + END_DOCUMENT);
    } else {
      send(event2JavaScript(anEvent));
    }
  }
Ejemplo n.º 2
0
  /** Send any string to browser. */
  protected void send(String s) throws IOException {
    // Send string to browser.
    // Log.debug("Adapter: sending: " + s);
    if (servletOut == null) {
      throw new IOException("Client adapter was stopped");
    }

    servletOut.print(s);

    servletOut.flush();

    // Note: this doesn't seem to have effect
    // in Tomcat 4/5 if the client already disconnected.
    servletRsp.flushBuffer();

    bytesSent += s.length();
    Log.debug("bytesSent= " + bytesSent);
    // Log.debug("BCA sent event: " + s);
  }
Ejemplo n.º 3
0
 /** Exceptional print util. */
 public void debug(String s) {
   Log.debug("S-" + this + ": " + s);
 }
Ejemplo n.º 4
0
 /** Exceptional print util. */
 public void warn(String s) {
   Log.warn("S-" + this + ": " + s);
 }
Ejemplo n.º 5
0
 /** Info. */
 public void info(String s) {
   Log.info("S-" + this + ": " + s);
 }