Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Copyright (c) xsocket.org, 2006 - 2008. All rights reserved.
   *
   *  This library is free software; you can redistribute it and/or
   *  modify it under the terms of the GNU Lesser General Public
   *  License as published by the Free Software Foundation; either
   *  version 2.1 of the License, or (at your option) any later version.
   *
   *  This library is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *  Lesser General Public License for more details.
  *
  *  You should have received a copy of the GNU Lesser General Public
  *  License along with this library; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * Please refer to the LGPL license at: http://www.gnu.org/copyleft/lesser.txt
  * The latest copy of this software may be found on http://www.xsocket.org/
  */
 package org.xsocket.connection.multiplexed.multiplexer;
 
 
The mulitplexer is responsible to multiplex and demultiplex th pipeline stream based on the underlying org.xsocket.connection.INonBlockingConnection

Author(s):
grro@xsocket.org
 
 public interface IMultiplexer  {

opens a new pipelinie

Parameters:
connection the underlying connection
Returns:
the global (over the time) unique pipeline id
Throws:
java.io.IOException if an exception occurs
java.nio.channels.ClosedChannelException if the connection is closed
 
closes a open pipeline

Parameters:
connection the underlyind connection
pipelineId the pipeline id
Throws:
java.io.IOException if an exception occurs
java.nio.channels.ClosedChannelException if the connection is closed
 
 	public void closePipeline(INonBlockingConnection connectionString pipelineIdthrows IOExceptionClosedChannelException;


writes (multiplexes) the pipeline data to the underlying connection

Parameters:
connection the underlying connection
pipelineId the pipeline id
dataToWrite the pipeline data to write
Throws:
java.io.IOException if an exception occurs
java.nio.channels.ClosedChannelException if the connection is closed
 
 	public void multiplex(INonBlockingConnection connectionString pipelineIdByteBuffer[] dataToWritethrows IOExceptionClosedChannelException;


reads (demultiplexes) pipeline data/open/close events from the underlying connection

Parameters:
connection the underlying connection
resultHandler the result handler
Throws:
java.io.IOException if an exception occurs
java.nio.channels.ClosedChannelException if the connection is closed
 
 	public void demultiplex(INonBlockingConnection connectionIDemultiplexResultHandler resultHandlerthrows IOExceptionClosedChannelException;




The result handler to consume the specific call back notifications

Author(s):
grro@xsocket.org
 
 	public interface IDemultiplexResultHandler {

call back if a pipeline has been opened by the peer

Parameters:
pipelineId the pipeline id
 
 		public void onPipelineOpend(String pipelineId);


call back if a pipeline has been closed by the peer

Parameters:
pipelineId the pipeline id
		public void onPipelineClosed(String pipelineId);


call back if data has been received for a pipeline

Parameters:
pipelineId the pipeline id
data the received pipeline data
		public void onPipelineData(String pipelineIdByteBuffer[] data);
	}
New to GrepCode? Check out our FAQ X