jadex.base.service.message.streams.LocalOutputConnectionHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-base Show documentation
Show all versions of jadex-platform-base Show documentation
The Jadex platform base package contains
functionality useful for constructing platforms.
The newest version!
package jadex.base.service.message.streams;
import java.util.Map;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
/**
*
*/
public class LocalOutputConnectionHandler extends LocalAbstractConnectionHandler
implements IOutputConnectionHandler
{
/** The maximum bytes of data that can be stored in connection (without being consumed). */
protected int maxstored;
/**
*
*/
public LocalOutputConnectionHandler(Map nonfunc)
{
this(nonfunc, null);
}
/**
*
*/
public LocalOutputConnectionHandler(Map nonfunc, LocalAbstractConnectionHandler conhandler)
{
super(nonfunc, conhandler);
}
//-------- methods called from connection --------
/**
* Called from connection.
*/
public IFuture send(final byte[] data)
{
((LocalInputConnectionHandler)getConnectionHandler()).dataReceived(data);
return IFuture.DONE;
}
/**
* Flush the data.
*/
public void flush()
{
}
/**
* Wait until the connection is ready for the next write.
* @return Calls future when next data can be written.
*/
public IFuture waitForReady()
{
// todo: how to implement locally without timer :-( ?
return new Future(32768); // todo: useful value?
}
// /**
// * Test if stop is activated (too much data arrived).
// */
// protected boolean isStop()
// {
// return getInputConnection().getStoredDataSize()>=maxstored;
// }
}