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

org.glassfish.websocket.api.Conversation Maven / Gradle / Ivy

The newest version!
/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2011 - 2012 Oracle and/or its affiliates. All rights reserved.
 *
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common Development
 * and Distribution License("CDDL") (collectively, the "License").  You
 * may not use this file except in compliance with the License.  You can
 * obtain a copy of the License at
 * http://glassfish.java.net/public/CDDL+GPL_1_1.html
 * or packager/legal/LICENSE.txt.  See the License for the specific
 * language governing permissions and limitations under the License.
 *
 * When distributing the software, include this License Header Notice in each
 * file and include the License file at packager/legal/LICENSE.txt.
 *
 * GPL Classpath Exception:
 * Oracle designates this particular file as subject to the "Classpath"
 * exception as provided by Oracle in the GPL Version 2 section of the License
 * file that accompanied this code.
 *
 * Modifications:
 * If applicable, add the following below the License Header, with the fields
 * enclosed by brackets [] replaced by your own identifying information:
 * "Portions Copyright [year] [name of copyright owner]"
 *
 * Contributor(s):
 * If you wish your version of this file to be governed by only the CDDL or
 * only the GPL Version 2, indicate your decision by adding "[Contributor]
 * elects to include this software in this distribution under the [CDDL or GPL
 * Version 2] license."  If you don't indicate a single choice of license, a
 * recipient has the option to distribute your version of this file under
 * either the CDDL, the GPL Version 2 or to extend the choice of license to
 * its licensees as provided above.  However, if you add GPL Version 2 code
 * and therefore, elected the GPL Version 2 license, then the option applies
 * only if the new code is made subject to such option by the copyright
 * holder.
 */

package org.glassfish.websocket.api;

import javax.servlet.http.HttpSession;
import java.util.*;
import java.io.*;

/**
 * A Conversation represents the sequence of bi-directional messages between an end point
 * and one of its remote peers. It's a bit like the web socket equivalent of an HttpSession
 * in servlet programming.
 * @author dannycoward
 */


public interface Conversation {

    /** Obtain a reference to the remote object with which this
     * conversation is happening. */

    public T getPeer();
    /** Test whether this conversation is active. I.e. is the underlying
     * websocket connection alive or not.
     * @return
     */
    public boolean isActive();

    /** Return the time when this conversation started.*/
    public Date getActivationTime();

    /** Return the web socket sub protocol used in this conversation, as agreed in the
     * initial handshake.
     * @return
     */
    public String getSubprotocol();

    /** Obtain the HttpSession that this web socket conversation is part of, if embedded in
     * a servlet container. Otherwise, null. For example, if this conversation was initiated by
     * a javascript web socket call from a JSP page, then the HttpSession is the HttpSession
     * that was created when the JSP was first called.
     * @return
     */
    public HttpSession getHttpSession();
     /** A read/write map of properties. An end point may use this to share
     * data throughout the lifetime of web socket conversation.
     * @return
     */
    public Map getProperties();

     /** Return a unique ID for this conversation.*/
    public Long getConversationID();

    /** Closes the underlying connection this session is based upon, using a CloseCode and a reason. */
    public void deactivate(int code, String reason) throws IOException;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy