All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mortbay.cometd.IFrameTransport Maven / Gradle / Ivy

There is a newer version: 6.1.11
Show newest version
package org.mortbay.cometd;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

public class IFrameTransport extends AbstractTransport
{
    PrintWriter _writer;
    boolean _initialized=false;

    public void setResponse(HttpServletResponse response) throws IOException
    {
        _initialized=false;
        super.setResponse(response);
    }

    private void init(Map reply) throws IOException
    {
        if (_initialized)
            return;
        _initialized=true;
        
        String channel=(String)reply.get("channel");
        if (!"/meta/connect".equals(channel)&&!"/meta/reconnect".equals(channel))
            reply=null;

        getResponse().setContentType("text/html; charset=UTF-8");
        _writer=getResponse().getWriter();

        _writer.println("");
        _writer.println("");
        _writer.println("");
        _writer.println("");
        _writer.println("cometd: over jetty");

        if (reply!=null)
        {
            _writer.write("");
        }
        _writer.println("");
        _writer.println("");
        _writer.flush();
    }

    public void send(Map reply) throws IOException
    {
        if (!_initialized)
            init(reply);
        else
        {
            _writer.write("

"); for (int i=0; i<16; i++) _writer.write(" "); _writer.write("
"); _writer.flush(); } } public void send(List replies) throws IOException { if (replies==null) return; int m=0; if (!_initialized) { if (replies.size()>0) init((Map)replies.get(m++)); else init(null); } if (replies.size()>m) { _writer.write("

"); for (int i=0; i<16; i++) _writer .write(" "); _writer.write("
"); _writer.flush(); } } public void complete() throws IOException { // _writer.write(""); _writer.write(""); _writer.write(""); _writer.flush(); } public boolean keepAlive() throws IOException { return false; } public void initTunnel(HttpServletResponse response) throws IOException { response.setContentType("text/html; charset=utf-8"); _writer=response.getWriter(); _writer.println(""); _writer.println(""); _writer.println(""); _writer.println(" "); _writer.println(" cometd: The Long Tail of Comet"); _writer.println(" "); _writer.println(" "); _writer.println(" "); _writer.println(" "); _writer.println("

cometd: The Long Tail of Comet

"); _writer.println(" "); _writer.println(""); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy