/*
 *  Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. 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.wso2.carbon.connector.framework.websocket;

/**
 * This is the common interface for all WebSocket messages.
 * <b>Note: Use this interface in the application level only and only if the user needs only the channel details
 * of a WebSocket message otherwise use the extensions of this interface.</b>
 */
public interface WebSocketChannelContext {

    /**
     * Retrieve negotiated sub-protocol.
     *
     * @return the negotiated sub-protocol.
     */
    String getSubProtocol();

    /**
     * Retrieve the target of the application as a String.
     *
     * @return the target of the application.
     */
    String getTarget();

    /**
     * Retrieve the listener port of the the incoming message.
     *
     * @return the listener port.
     */
    String getListenerPort();

    /**
     * Retrieve the WebSocket protocol version.
     *
     * @return the protocol version of the given channel.
     */
    String getWebSocketProtocolVersion();

    /**
     * Check whether the given connection is secured or not.
     *
     * @return true if the connection is secured.
     */
    boolean isConnectionSecured();
}

/*
 *  Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. 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.wso2.carbon.connector.framework.websocket;

/**
 * This is the common interface for all WebSocket messages.
 * <b>Note: Use this interface in the application level only and only if the user needs only the channel details
 * of a WebSocket message otherwise use the extensions of this interface.</b>
 */
public interface WebSocketChannelContext {

    /**
     * Retrieve negotiated sub-protocol.
     *
     * @return the negotiated sub-protocol.
     */
    String getSubProtocol();

    /**
     * Retrieve the target of the application as a String.
     *
     * @return the target of the application.
     */
    String getTarget();

    /**
     * Retrieve the listener port of the the incoming message.
     *
     * @return the listener port.
     */
    String getListenerPort();

    /**
     * Retrieve the WebSocket protocol version.
     *
     * @return the protocol version of the given channel.
     */
    String getWebSocketProtocolVersion();

    /**
     * Check whether the given connection is secured or not.
     *
     * @return true if the connection is secured.
     */
    boolean isConnectionSecured();

    /**
     * Check whether the message is coming from server connector or client connector.
     *
     * @return true if the message is coming from server connector else return false if the message is coming from
     * client connector.
     */
    boolean isServerMessage();
}

Introduce method to check the inbound message source