mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/transport/TransportChannelImpl.java
private boolean sendMessage(final TerraHarvestMessage message, final TransportLayer transport,
            final Address remoteAddress)
    {
        final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        try
        {
            message.writeDelimitedTo(outStream);
        }
        catch (final IOException e)
        {
            // this should never happen has stream used never throws IOException
            throw new IllegalStateException("Unable to write to byte array", e);
        }
        
        try
        {
            if (m_TransportCapabilities.isConnectionOriented())
            {
                transport.send(ByteBuffer.wrap(outStream.toByteArray()));
            }
            else
            {
                transport.send(ByteBuffer.wrap(outStream.toByteArray()), remoteAddress);
            }
        }
        catch (final IllegalStateException e)
        {
            setStatusAndLog(ChannelStatus.Unknown, 
                    String.format("Tried to send remote message with transport [%s] in unknown state, %s", 
                            transport.getName(), e.getMessage()));
            return false;
        }
        catch (final CCommException e)
        {
            setStatusAndLog(ChannelStatus.Unavailable, 
                    String.format("Failed to send remote message to address [%s], %s", getRemoteMessageAddress(), 
                            e.getMessage()));
            return false;
        }
        
        return true;
    }
/**
     * Sends a {@link TerraHarvestMessage} via a transport layer to the specified remote address.
     * The transport layer can be either a connection oriented or non-connection oriented layer. 
     * @param message
     *  the {@link TerraHarvestMessage} to send
     * @param transport
     *  the {@link TransportLayer} to use for sending
     * @param remoteAddress
     *  the remote {@link Address} to send the message to
     * @return
     *  true if the message sending was successful
     */
Sends a  TerraHarvestMessage via a transport layer to the specified remote address.
The transport layer can be either a connection oriented or non-connection oriented layer.
@param message
the  TerraHarvestMessage to send
@param transport
the  TransportLayer to use for sending
@param remoteAddress
the remote  Address to send the message to
@return
true if the message sending was successful
Sends a TerraHarvestMessage via a transport layer to the specified remote address . The transport layer can be either a connection oriented or non - connection oriented layer . @param message the TerraHarvestMessage to send @param transport the TransportLayer to use for sending @param remoteAddress the remote Address to send the message to @return true if the message sending was successful
private boolean sendMessage(final TerraHarvestMessage message, final TransportLayer transport,
            final Address remoteAddress)
    {
        final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        try
        {
            message.writeDelimitedTo(outStream);
        }
        catch (final IOException e)
        {
            throw new IllegalStateException("Unable to write to byte array", e);
        }
        try
        {
            if (m_TransportCapabilities.isConnectionOriented())
            {
                transport.send(ByteBuffer.wrap(outStream.toByteArray()));
            }
            else
            {
                transport.send(ByteBuffer.wrap(outStream.toByteArray()), remoteAddress);
            }
        }
        catch (final IllegalStateException e)
        {
            setStatusAndLog(ChannelStatus.Unknown, 
                    String.format("Tried to send remote message with transport [%s] in unknown state, %s", 
                            transport.getName(), e.getMessage()));
            return false;
        }
        catch (final CCommException e)
        {
            setStatusAndLog(ChannelStatus.Unavailable, 
                    String.format("Failed to send remote message to address [%s], %s", getRemoteMessageAddress(), 
                            e.getMessage()));
            return false;
        }
        return true;
    }
private boolean sendMessage ( final TerraHarvestMessage message , final TransportLayer transport , final Address remoteAddress ) { final ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ; try { message . writeDelimitedTo ( outStream ) ; } catch ( final IOException e ) { throw new IllegalStateException ( "Unable to write to byte array" , e ) ; } try { if ( m_TransportCapabilities . isConnectionOriented ( ) ) { transport . send ( ByteBuffer . wrap ( outStream . toByteArray ( ) ) ) ; } else { transport . send ( ByteBuffer . wrap ( outStream . toByteArray ( ) ) , remoteAddress ) ; } } catch ( final IllegalStateException e ) { setStatusAndLog ( ChannelStatus . Unknown , String . format ( "Tried to send remote message with transport [%s] in unknown state, %s" , transport . getName ( ) , e . getMessage ( ) ) ) ; return false ; } catch ( final CCommException e ) { setStatusAndLog ( ChannelStatus . Unavailable , String . format ( "Failed to send remote message to address [%s], %s" , getRemoteMessageAddress ( ) , e . getMessage ( ) ) ) ; return false ; } return true ; }
Sends a {@link TerraHarvestMessage} via a transport layer to the specified remote address.
Sends a { @link TerraHarvestMessage } via a transport layer to the specified remote address .
// this should never happen has stream used never throws IOException