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

org.apache.guacamole.servlet.GuacamoleHTTPTunnel Maven / Gradle / Ivy

Go to download

The base Java API of the Guacamole project, providing Java support for the Guacamole stack.

There is a newer version: 1.5.5
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.guacamole.servlet;

import org.apache.guacamole.net.DelegatingGuacamoleTunnel;
import org.apache.guacamole.net.GuacamoleTunnel;

/**
 * Tracks the last time a particular GuacamoleTunnel was accessed. This
 * information is not necessary for tunnels associated with WebSocket
 * connections, as each WebSocket connection has its own read thread which
 * continuously checks the state of the tunnel and which will automatically
 * timeout when the underlying socket times out, but the HTTP tunnel has no
 * such thread. Because the HTTP tunnel requires the stream to be split across
 * multiple requests, tracking of activity on the tunnel must be performed
 * independently of the HTTP requests.
 *
 * @author Michael Jumper
 */
class GuacamoleHTTPTunnel extends DelegatingGuacamoleTunnel {

    /**
     * The last time this tunnel was accessed.
     */
    private long lastAccessedTime;

    /**
     * Creates a new GuacamoleHTTPTunnel which wraps the given tunnel.
     * Absolutely all function calls on this new GuacamoleHTTPTunnel will be
     * delegated to the underlying GuacamoleTunnel.
     *
     * @param wrappedTunnel
     *     The GuacamoleTunnel to wrap within this GuacamoleHTTPTunnel.
     */
    public GuacamoleHTTPTunnel(GuacamoleTunnel wrappedTunnel) {
        super(wrappedTunnel);
    }

    /**
     * Updates this tunnel, marking it as recently accessed.
     */
    public void access() {
        lastAccessedTime = System.currentTimeMillis();
    }

    /**
     * Returns the time this tunnel was last accessed, as the number of
     * milliseconds since midnight January 1, 1970 GMT. Tunnel access must
     * be explicitly marked through calls to the access() function.
     *
     * @return
     *     The time this tunnel was last accessed.
     */
    public long getLastAccessedTime() {
        return lastAccessedTime;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy