{
serialize( Channels.newOutputStream( _channel ), obj, clientInfo );
// default mode: deserialize the server response
if ( !clientInfo.isMixed() )
{
result = deserialize( new ChannelInputStream( Channels.newInputStream( _channel ) ), clientInfo );
}
// mixed mode: don't deserialize the server response
else
{
result = IOUtil.readDirect( new ChannelInputStream( Channels.newInputStream( _channel ) ) );
}
}
// direct mode: don't (de)serialize, just copy and return the read
// ByteBuffer
else
{
ByteBuffer tmp = (ByteBuffer) obj;
if ( tmp.position() > 0 )
{
tmp.flip();
}
IOUtil.writeDirect( Channels.newOutputStream( _channel ), tmp );
result = IOUtil.readDirect( new ChannelInputStream( Channels.newInputStream( _channel ) ) );
}
return result;
}