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

org.socketio.netty.session.IManagedSession Maven / Gradle / Ivy

/**
 * Copyright 2012 Ronen Hamias, Anton Kharenko
 *
 * Licensed 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.socketio.netty.session;

import org.socketio.netty.ISession;
import org.socketio.netty.ISessionFuture;
import org.socketio.netty.packets.Packet;

import io.netty.channel.Channel;

/**
 * This interface enrich ISession interface with control methods required to manage 
 * session internally. This interface is not supposed to be used by users of the library 
 * and represents internal details session implementation and subject to change
 * in future versions.  
 * 
 * @author Anton Kharenko
 *
 */
public interface IManagedSession extends ISession {
	
	/**
	 * Connects current session to given channel.
	 * 
	 * @param channel
	 *            channel to which client connected
	 * @return true if this is initial connection for this session; false otherwise.
	 * 
	 */
	boolean connect(final Channel channel);
	
	/**
	 * Disconnect this session.
	 * 
	 * @param channel the channel to use for disconnection
	 */
	void disconnect(final Channel channel);
	
	/**
	 * Send heartbeat packet to client.
	 */
	ISessionFuture sendHeartbeat();
	
	/**
	 * Send packet message to client.
	 * 
	 * @param messagePacket message to be sent to client
	 */
	ISessionFuture sendPacket(final Packet messagePacket);
	
	/**
	 * Send acknowledgment (e.g. HTTP 200) to client that message was accepted
	 * 
	 * @param channel channel to which client connected
	 */
	void acceptPacket(final Channel channel, final Packet packet);
	
	/**
	 * Reschedule heartbeats for this client. 
	 */
	void acceptHeartbeat();
	
	/**
	 * Marks session as upgraded when session is going to be 
	 * upgraded to another transport type. 
	 */
	void markAsUpdgraded();
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy